Description
Fix broken web UI (Test page overlay) by providing Authentication support.
Cause of broken UI
Due to the Keycloak Security Configuration brought into the JPA Server code, API redirects it to the default login page of the Keycloak as per the default behavior that response is in the html/text
format. But as per the CapabilityStatement.class
, the mentioned content type is not supported by the API content type.
This breaks while fetching and loading the Conformance Statement that has all the set of rules to which the FHIR Application is compliant. It throws away NonFHIRResponseException at
https://github.com/opensrp/hapi-fhir/blob/38436e5c1bd04e7a4ca81f078eb18ddabc2bd533/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java#L576
Possible Solution
-
Redirect to the default Keycloak Login form whenever "/" end-point is triggered
-
Save username/password in a map (until a session is expired) to be used later
-
Keycloak Fetch Token API should be triggered every time an API is triggered
-
Introduce an Interceptor to add an
Authorization
header with theBearer token
fetched above -
Possible Hook to be used here is:
@Hook(Pointcut.SERVER_INCOMING_REQUEST_PRE_PROCESSED)
-
We need to add logic to check if there is an already existing
Authorization header
present in the HTTP Request then skip this step.
Challenges/Open questions
- How to keep track of user active sessions?