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

Modify fhir-smart behavior for "user/" scope requests #3495

Closed
lmsurpre opened this issue Mar 22, 2022 · 1 comment
Closed

Modify fhir-smart behavior for "user/" scope requests #3495

lmsurpre opened this issue Mar 22, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@lmsurpre
Copy link
Member

lmsurpre commented Mar 22, 2022

Is your feature request related to a problem? Please describe.
In the current implementation, we require the access token to have a patient_id claim for basically any search for resource types that can exist in the patient compartment.

However, for access tokens with user/ or system/ scopes, that feels a bit inconsistent with our isAllowed implementation which basically allows access to any resources when the access token contains a scope with a valid permission for the current interaction (e.g. user/Patient.read for searching patient resources).

This leads to confusing behavior like what is reported at https://chat.fhir.org/#narrow/stream/212434-ibm/topic/Custom.20Sort.20Parameters/near/275813474 where a search of the Basic endpoint with a scope like user/Basic.read ends in 0 results but a whole-system search with the same scope can retrieve these resources just fine.

Describe the solution you'd like

  1. Only require the patient_id claim for patient/ scopes (and only when a corresponding user/ or system/ scope doesn't cover the interaction).
  2. Only scope searches to the patient compartment when the patient/ scope is the only one that allows the interaction.

Describe alternatives you've considered
more clearly document that the patient_id claim is required even for user/ scopes and ensure that these are enforced properly as part of whole-system search.

Acceptance Criteria

  1. GIVEN a server with multiple patient resources (a, b, c)
    AND a valid access token with patient_id=a and scope=launch/patient patient/*.read
    WHEN a search request would return a resource type that is in the the patient compartment
    THEN only resources in the compartment of patient a are returned

  2. GIVEN a server with multiple patient resources (a, b, c)
    AND a valid access token with scopes that include user/*.read (with or without a patient_id claim)
    WHEN a search request would return a resource type that is in the the patient compartment
    THEN all resources that meet the search criteria are returned without regard to any patient_id claim/context

  3. GIVEN a server with multiple patient resources (a, b, c)
    AND a valid access token with scopes that include system/*.read (with or without a patient_id claim)
    WHEN a search request would return a resource type that is in the the patient compartment
    THEN all resources that meet the search criteria are returned without regard to any patient_id claim/context

Additional context
See https://chat.fhir.org/#narrow/stream/212434-ibm/topic/GET.20Patients and https://chat.fhir.org/#narrow/stream/212434-ibm/topic/fhir-smart/near/264451208 for related discussion.

@lmsurpre lmsurpre added the enhancement New feature or request label Mar 22, 2022
@lmsurpre lmsurpre self-assigned this Mar 22, 2022
lmsurpre added a commit that referenced this issue Mar 23, 2022
Specifically, avoid adding the implicit compartment parameter(s) when
the interaction is covered by one or more tokens with the 'user/' or
'system/' prefix ("context type")

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Mar 23, 2022
Also addressed review comments by adding class-level javadoc

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Mar 24, 2022
Also addressed review comments by adding class-level javadoc

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Mar 24, 2022
Also addressed review comments by adding class-level javadoc

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Mar 31, 2022
issue #3495 - more selectively scope searches to patient compartment
@d0roppe
Copy link
Collaborator

d0roppe commented Apr 4, 2022

Verified that this is working as outlined in the Acceptance criteria above. Closing issue.

@d0roppe d0roppe closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants