Class: SMARTAppLaunch::TokenExchangeSTU22Test

Inherits:
TokenExchangeSTU2Test show all
Defined in:
lib/smart_app_launch/token_exchange_stu2_2_test.rb

Instance Method Summary collapse

Instance Method Details

#add_credentials_to_request(oauth2_params, oauth2_headers) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/smart_app_launch/token_exchange_stu2_2_test.rb', line 7

def add_credentials_to_request(oauth2_params, oauth2_headers)
  if client_auth_type == 'confidential_symmetric'
    assert client_secret.present?,
           'A client secret must be provided when using confidential symmetric client authentication.'

    client_credentials = "#{client_id}:#{client_secret}"
    oauth2_headers['Authorization'] = "Basic #{Base64.strict_encode64(client_credentials)}"
  elsif client_auth_type == 'public'
    oauth2_params[:client_id] = client_id
    oauth2_headers['Origin'] = Inferno::Application['inferno_host']
  else
    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:
      )
    )
  end
end