dvidsilva
11/29/2023, 6:01 PMrahul1
11/30/2023, 1:04 AMsignOut
method. https://www.medplum.com/docs/sdk/core.medplumclient.signout
2. This document talks a bit more about projects, including how to access the super admin project. Let me know if you have any more questionsL: https://www.medplum.com/docs/access/projectsdvidsilva
11/30/2023, 1:34 AMeversgregly
11/30/2023, 5:36 PMsubject
, but I find that I can use the token to create responses for arbitrary patients, not just the one specified in this following scope
header that I sent to `oauth2/token`:
openid patient/QuestionnaireResponse.c Questionnaire.rs
Now, this isn't a surprise to me necessarily, because HL7's SMART spec (https://hl7.org/fhir/smart-app-launch/backend-services.html#scopes) seems to say that the patient/
prefix is meaningless unless the patient is the one who logged in, but Medplum's own SMART scope documentation (https://hl7.org/fhir/smart-app-launch/backend-services.html#scopes) suggests that this should work so long as I provide the additional HTTP header patient=PATIENT_ID
. Is there something I'm missing, or do we just need to log in as the patient if we want to achieve this sort of security?
PS: Perhaps less pressingly, I noticed that if I remove the patient/
prefix from patient/QuestionnaireResponse.c
then the server lets me create new patients with the access token and forbids me otherwise. I'm not sure what that's all about.
PPS: I'm running Medplum server v2.1.20 on my local machine, and I will post example requests and responses in a followup message.eversgregly
11/30/2023, 5:42 PMcurl --location 'localhost:8103/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--header 'Authorization: Basic CLIENT_ID_AND_SECRET' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=openid patient/QuestionnaireResponse.c Questionnaire.r' \
--data-urlencode 'patient=AUTHORIZED_PATIENT_ID'
eversgregly
11/30/2023, 5:44 PMcurl --location 'localhost:8103/fhir/R4/QuestionnaireResponse' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--data '{
"resourceType": "QuestionnaireResponse",
"subject": {
"reference": "Patient/AUTHORIZED_PATIENT_ID"
}
}'
Response:
{
"resourceType": "QuestionnaireResponse",
"subject": {
"reference": "Patient/AUTHORIZED_PATIENT_ID"
},
"id": "cda58d50-a664-4685-a360-3ad8ece11c46",
"meta": {
"versionId": "57f9173d-af39-459a-86a4-f3ca5611db4c",
"lastUpdated": "2023-11-30T17:42:49.042Z"
}
}
eversgregly
11/30/2023, 5:50 PMcurl --location 'localhost:8103/fhir/R4/QuestionnaireResponse' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--data '{
"resourceType": "QuestionnaireResponse",
"subject": {
"reference": "Patient/UNAUTHORIZED_PATIENT_ID"
}
}'
And the response:
{
"resourceType": "QuestionnaireResponse",
"subject": {
"reference": "Patient/UNAUTHORIZED_PATIENT_ID"
},
"id": "04b9ec21-5343-4a90-9ee0-287543851841",
"meta": {
"versionId": "441c6c51-d2ae-435b-abb5-ca3e1d87bb94",
"lastUpdated": "2023-11-30T17:46:49.382Z"
}
}
rahul1
12/04/2023, 11:28 PMadmin@example.com
is the only user registered in the Super Admin project. After you login using those credentials, you can invite your own user to the project https://www.medplum.com/docs/contributing/run-the-stack#start-the-serversrahul1
12/04/2023, 11:50 PMdvidsilva
12/05/2023, 10:42 PM