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

Added client_id OAuth 2.0 support to CDSHooks service #701

Merged
merged 1 commit into from
Apr 14, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

private String clientIdHeaderName;

public String getClientIdHeaderName() {
return clientIdHeaderName;
}

public void setClientIdHeaderName(String clientIdHeaderName) {
this.clientIdHeaderName = clientIdHeaderName;
}

private FhirServer fhirServer = new FhirServer();

public FhirServer getFhirServer() {
Expand All @@ -27,7 +37,7 @@ public void setFhirServer(FhirServer fhirServer) {
this.fhirServer = fhirServer;
}

public class FhirServer {
public static class FhirServer {
private Integer maxCodesPerQuery;

public Integer getMaxCodesPerQuery() {
Expand Down Expand Up @@ -79,7 +89,7 @@ public void setPrefetch(Prefetch prefetch) {
this.prefetch = prefetch;
}

public class Prefetch {
public static class Prefetch {
private Integer maxUriLength;

public Integer getMaxUriLength() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
useServerData = new BooleanType(false);
remoteDataEndpoint = new Endpoint().setAddress(cdsHooksRequest.fhirServer);
if (cdsHooksRequest.fhirAuthorization != null) {
remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType + ": "
+ cdsHooksRequest.fhirAuthorization.accessToken);
remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType
+ ": " + cdsHooksRequest.fhirAuthorization.accessToken);
if (cdsHooksRequest.fhirAuthorization.subject != null) {
remoteDataEndpoint.addHeader(this.getProviderConfiguration().getClientIdHeaderName()
+ ": " + cdsHooksRequest.fhirAuthorization.subject);
}
}
}
Bundle data = CdsHooksUtil.getPrefetchResources(cdsHooksRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@

public class ProviderConfiguration {

public static final ProviderConfiguration DEFAULT_PROVIDER_CONFIGURATION = new ProviderConfiguration(true, null,
SearchStyleEnum.GET, 8000, false, null);
public static final ProviderConfiguration DEFAULT_PROVIDER_CONFIGURATION = new ProviderConfiguration(true, 64,
SearchStyleEnum.GET, 8000, false, 5, "client_id");

private Integer maxCodesPerQuery;
private SearchStyleEnum searchStyle;
private boolean expandValueSets;
private Integer queryBatchThreshold;
private int maxUriLength;
private boolean cqlLoggingEnabled;
private final Integer maxCodesPerQuery;
private final SearchStyleEnum searchStyle;
private final boolean expandValueSets;
private final Integer queryBatchThreshold;
private final Integer maxUriLength;
private final String clientIdHeaderName;
private final boolean cqlLoggingEnabled;

public ProviderConfiguration(boolean expandValueSets, Integer maxCodesPerQuery, SearchStyleEnum searchStyle,
int maxUriLength, boolean cqlLoggingEnabled, Integer queryBatchThreshold) {
Integer maxUriLength, boolean cqlLoggingEnabled, Integer queryBatchThreshold, String clientIdHeaderName) {
this.maxCodesPerQuery = maxCodesPerQuery;
this.searchStyle = searchStyle;
this.expandValueSets = expandValueSets;
this.maxUriLength = maxUriLength;
this.cqlLoggingEnabled = cqlLoggingEnabled;
this.queryBatchThreshold = queryBatchThreshold;
this.clientIdHeaderName = clientIdHeaderName;
}

public ProviderConfiguration(CdsHooksProperties cdsProperties, CqlProperties cqlProperties) {
Expand All @@ -33,6 +35,7 @@ public ProviderConfiguration(CdsHooksProperties cdsProperties, CqlProperties cql
this.searchStyle = cdsProperties.getFhirServer().getSearchStyle();
this.maxUriLength = cdsProperties.getPrefetch().getMaxUriLength();
this.queryBatchThreshold = cdsProperties.getFhirServer().getQueryBatchThreshold();
this.clientIdHeaderName = cdsProperties.getClientIdHeaderName();
this.cqlLoggingEnabled = cqlProperties.getOptions().getCqlEngineOptions().isDebugLoggingEnabled();
}

Expand All @@ -50,10 +53,14 @@ public boolean getExpandValueSets() {

public Integer getQueryBatchThreshold() { return this.queryBatchThreshold; }

public int getMaxUriLength() {
public Integer getMaxUriLength() {
return this.maxUriLength;
}

public String getClientIdHeaderName() {
return this.clientIdHeaderName;
}

public boolean getCqlLoggingEnabled() {
return this.cqlLoggingEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
useServerData = new BooleanType(false);
remoteDataEndpoint = new Endpoint().setAddress(cdsHooksRequest.fhirServer);
if (cdsHooksRequest.fhirAuthorization != null) {
remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType + ": "
+ cdsHooksRequest.fhirAuthorization.accessToken);
remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType
+ ": " + cdsHooksRequest.fhirAuthorization.accessToken);
if (cdsHooksRequest.fhirAuthorization.subject != null) {
remoteDataEndpoint.addHeader(this.getProviderConfiguration().getClientIdHeaderName()
+ ": " + cdsHooksRequest.fhirAuthorization.subject);
}
}
}
Bundle data = CdsHooksUtil.getPrefetchResources(cdsHooksRequest);
Expand Down
1 change: 1 addition & 0 deletions plugin/cds-hooks/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ hapi:
fhir:
cdshooks:
enabled: true
clientIdHeaderName: client_id
fhirserver:
expandValueSets: true
maxCodesPerQuery: 64
Expand Down
7 changes: 4 additions & 3 deletions server/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ hapi:
## CDS Hook Settings
cdshooks:
enabled: true
clientIdHeaderName: client_id
fhirserver:
# expandValueSets: true
# maxCodesPerQuery: 64
# queryBatchThreshold: 10
expandValueSets: true
maxCodesPerQuery: 64
queryBatchThreshold: 5
searchStyle: GET
prefetch:
maxUriLength: 8000