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

Limit HAPI query scope to resources associated with the logged in user (config-enabled) #12

Open
mcjustin opened this issue Apr 2, 2024 · 2 comments
Assignees

Comments

@mcjustin
Copy link
Member

mcjustin commented Apr 2, 2024

Use case (Let's Talk Tech aka LTT): patients log on to a front-end only app (SHL creator, https://github.com/uwcirg/shl-ltt) that uses jwt-proxy. We want to prevent the patient from using that app to CRUD resources that are associated with other patients. The resources in this use case include only Patient and DocumentReference.

In LTT, dhair2 saves the KC user ID to the Patient resource as an identifier, and then the SHL creator uses that identifier when querying for resources related to it:
https://fhir-auth.inform.dev.cirg.uw.edu/fhir/Patient?identifier=3dfb8924-8e64-4ae0-b823-1baf66657000
https://fhir-auth.inform.dev.cirg.uw.edu/fhir/DocumentReference?_count=1000&_sort=-date&subject.identifier=3dfb8924-8e64-4ae0-b823-1baf66657000
... and when it POSTs to /DocumentReference with request body containing a conditional subject reference like Patient?identifier=[keycloak user id].

jwt-proxy will need to read the Keycloak user ID from the JWT (in payload/data: sub).

Aside: the SHL-viewer isn't a problem here, as it doesn't communicate with the FHIR server directly (instead, uses the https://github.com/uwcirg/shl-ltt-server).

Per https://www.pivotaltracker.com/story/show/187355462

@mcjustin
Copy link
Member Author

mcjustin commented Apr 2, 2024

Paul: Filter the request, not the response...
Note that jwt-proxy interprets patient identifier from the token depending on the launch mode (femr|epic).
Short-term, put this in a new branch and use that in LTT.
https://github.com/uwcirg/jwt-proxy/blob/main/jwt_proxy/api.py#L70

Longer term:
Configuration value to enable this mode: scope_filter
python module to determine if URL is good or bad.
Would be good if environments could declare that this module should be enabled.

@mcjustin
Copy link
Member Author

mcjustin commented Apr 3, 2024

Current PR for this: #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants