Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

40 : Add keycloak authentication in jpa server starter #251

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>${project.version}</version>
<version>5.4.1-PRE5-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -116,17 +116,23 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>${project.version}</version>
<version>5.4.1-PRE5-SNAPSHOT</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>${project.version}</version>
<version>5.4.1-PRE5-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>

<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-opensrp-security-config</artifactId>
<version>5.4.0-PRE5-SNAPSHOT</version>
</dependency>

<!-- HAPI-FHIR uses Logback for logging support. The logback library is included automatically by Maven as a part of the hapi-fhir-base dependency, but you also need to include a logging library. Logback
is used here, but log4j would also be fine. -->
<dependency>
Expand Down Expand Up @@ -314,7 +320,17 @@


</dependencies>

<!-- <dependencyManagement>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>org.keycloak.bom</groupId>-->
<!-- <artifactId>keycloak-adapter-bom</artifactId>-->
<!-- <version>13.0.0</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->
<!--</dependencies>-->
<!-- </dependencyManagement>-->
<build>

<pluginManagement>
Expand Down Expand Up @@ -390,6 +406,7 @@
<overlay>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<!-- <version>5.4.1-PRE5-SNAPSHOT</version>-->
</overlay>
</overlays>
<failOnMissingWebXml>false</failOnMissingWebXml>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/ca/uhn/fhir/jpa/starter/Application.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.starter;

import autoconfigure.KeycloakSecurityConfig;
import ca.uhn.fhir.jpa.mdm.MdmConfig;
import ca.uhn.fhir.jpa.starter.annotations.OnEitherVersion;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
Expand All @@ -9,8 +10,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
Expand All @@ -25,6 +30,7 @@
JpaRestfulServer.class})
@SpringBootApplication(exclude = {ElasticsearchRestClientAutoConfiguration.class})
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, MdmConfig.class})
@EnableAutoConfiguration(exclude = {ErrorMvcAutoConfiguration.class})
public class Application extends SpringBootServletInitializer {

public static void main(String[] args) {
Expand Down Expand Up @@ -52,7 +58,7 @@ public ServletRegistrationBean hapiServletRegistration() {
JpaRestfulServer jpaRestfulServer = new JpaRestfulServer();
beanFactory.autowireBean(jpaRestfulServer);
servletRegistrationBean.setServlet(jpaRestfulServer);
servletRegistrationBean.addUrlMappings("/fhir/*");
servletRegistrationBean.addUrlMappings("/fhir/rest/*");
servletRegistrationBean.setLoadOnStartup(1);

return servletRegistrationBean;
Expand Down
24 changes: 19 additions & 5 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
spring:
main:
allow-bean-definition-overriding: true
datasource:
url: 'jdbc:h2:file:./target/database/h2'
url: 'jdbc:postgresql://localhost:5432/hapi_fhir'
#url: jdbc:h2:mem:test_mem
username: sa
password: null
driverClassName: org.h2.Driver
username: postgres
password: root
driverClassName: org.postgresql.Driver
max-active: 15

# database connection pool size
Expand Down Expand Up @@ -110,7 +112,7 @@ hapi:
tester:
home:
name: Local Tester
server_address: 'http://localhost:8080/fhir'
server_address: 'http://localhost:8080/fhir/rest'
refuse_to_fetch_third_party_urls: false
fhir_version: R4
global:
Expand Down Expand Up @@ -153,3 +155,15 @@ hapi:
# protocol: 'http'
# schema_management_strategy: CREATE
# username: SomeUsername
#security:
# ignored: none
keycloak:
auth-server-url: https://cc3ddc230510.ngrok.io/auth/
realm: fhir-core
resource: fhir-core-server
credentials:
secret: b7747a19-f72f-4906-8892-8438ce2492be
ssl-required: external
# use-resource-role-mappings: true,
logging.level.org.springframework.web: trace
logging.level.org.apache: trace