15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/davinci_dtr_test_kit/endpoints/mock_authorization/token_endpoint.rb', line 15
def make_response
client_id =
access_token = JWT.encode({ inferno_client_id: client_id }, nil, 'none')
granted_scopes = SUPPORTED_SCOPES & requested_scopes
response_hash = { access_token:, scope: granted_scopes.join(' '), token_type: 'bearer', expires_in: 3600 }
if granted_scopes.include?('openid')
response_hash.merge!(id_token: create_id_token(client_id, fhir_user: granted_scopes.include?('fhirUser')))
end
fhir_context_input = find_test_input("#{input_group_prefix}_smart_fhir_context")
begin
fhir_context = JSON.parse(fhir_context_input)
rescue StandardError
fhir_context = nil
end
response_hash.merge!(fhirContext: fhir_context) if fhir_context
smart_patient_input = find_test_input("#{input_group_prefix}_smart_patient_id")
response_hash.merge!(patient: smart_patient_input) if smart_patient_input
response.body = response_hash.to_json
response.['Cache-Control'] = 'no-store'
response.['Pragma'] = 'no-cache'
response.['Access-Control-Allow-Origin'] = '*'
response.status = 200
end
|