Class: SignIn::Idme::Service
Instance Attribute Summary collapse
Instance Method Summary
collapse
configuration, #raise_backend_exception
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
12
13
14
|
# File 'lib/sign_in/idme/service.rb', line 12
def type
@type
end
|
Instance Method Details
#normalized_attributes(user_info, credential_level) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/sign_in/idme/service.rb', line 20
def normalized_attributes(user_info, credential_level)
attributes = case type
when Constants::Auth::IDME
idme_attributes(user_info)
when Constants::Auth::DSLOGON
dslogon_attributes(user_info)
when Constants::Auth::MHV
mhv_attributes(user_info)
end
attributes.merge(standard_attributes(user_info, credential_level))
end
|
#render_auth(state: SecureRandom.hex, acr: Constants::Auth::IDME_LOA1, operation: Constants::Auth::AUTHORIZE) ⇒ Object
14
15
16
17
18
|
# File 'lib/sign_in/idme/service.rb', line 14
def render_auth(state: SecureRandom.hex, acr: Constants::Auth::IDME_LOA1, operation: Constants::Auth::AUTHORIZE)
Rails.logger.info('[SignIn][Idme][Service] Rendering auth, ' \
"state: #{state}, acr: #{acr}, operation: #{operation}")
RedirectUrlGenerator.new(redirect_uri: auth_url, params_hash: auth_params(acr, state, operation)).perform
end
|
#token(code) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/sign_in/idme/service.rb', line 32
def token(code)
response = perform(
:post, config.token_path, token_params(code), { 'Content-Type' => 'application/json' }
)
Rails.logger.info("[SignIn][Idme][Service] Token Success, code: #{code}, scope: #{response.body[:scope]}")
response.body
rescue Common::Client::Errors::ClientError => e
raise_client_error(e, 'Token')
end
|
#user_info(token) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/sign_in/idme/service.rb', line 42
def user_info(token)
response = perform(:get, config.userinfo_path, nil, { 'Authorization' => "Bearer #{token}" })
decrypted_jwe = jwe_decrypt(JSON.parse(response.body))
jwt_decode(decrypted_jwe)
rescue Common::Client::Errors::ClientError => e
raise_client_error(e, 'UserInfo')
end
|