Class: SMARTAppLaunch::TokenRefreshSTU2Test

Inherits:
TokenRefreshTest show all
Includes:
TokenPayloadValidation
Defined in:
lib/smart_app_launch/token_refresh_stu2_test.rb

Constant Summary

Constants included from TokenPayloadValidation

SMARTAppLaunch::TokenPayloadValidation::FHIR_ID_REGEX, SMARTAppLaunch::TokenPayloadValidation::FHIR_RESOURCE_TYPES, SMARTAppLaunch::TokenPayloadValidation::NUMERIC_FIELDS, SMARTAppLaunch::TokenPayloadValidation::STRING_FIELDS

Instance Method Summary collapse

Methods included from TokenPayloadValidation

#check_fhir_context_canonical, #check_fhir_context_identifier, #check_fhir_context_reference, #check_for_missing_scopes, #validate_fhir_context, #validate_fhir_context_stu2_2, #validate_required_fields_present, #validate_scope_subset, #validate_token_field_types, #validate_token_type

Methods inherited from TokenRefreshTest

#make_auth_token_request

Instance Method Details

#add_credentials_to_request(oauth2_headers, oauth2_params) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/smart_app_launch/token_refresh_stu2_test.rb', line 23

def add_credentials_to_request(oauth2_headers, oauth2_params)
  case client_auth_type
  when 'public'
    oauth2_params['client_id'] = client_id
  when 'confidential_symmetric'
    assert client_secret.present?,
           "A client secret must be provided when using confidential symmetric client authentication."

    credentials = Base64.strict_encode64("#{client_id}:#{client_secret}")
    oauth2_headers['Authorization'] = "Basic #{credentials}"
  when 'confidential_asymmetric'
    oauth2_params.merge!(
      client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
      client_assertion: ClientAssertionBuilder.build(
        iss: client_id,
        sub: client_id,
        aud: smart_token_url,
        client_auth_encryption_method: client_auth_encryption_method
      )
    )
  end
end