Class: Warden::Cognito::JwkLoader
Instance Method Summary
collapse
included, #pool_identifier, #user_pool=
Instance Method Details
#call(options) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/warden/cognito/jwk_loader.rb', line 19
def call(options)
return { keys: [jwk.key.export] } if jwk.key.present?
cache.delete(jwk_url) if options[:invalidate]
cache.fetch(jwk_url, expires_in: 1.hour) do
JSON.parse(HTTP.get(jwk_url).body.to_s).deep_symbolize_keys
end
end
|
#issued?(token) ⇒ Boolean
13
14
15
16
17
|
# File 'lib/warden/cognito/jwk_loader.rb', line 13
def issued?(token)
::JWT.decode(token, nil, false).first['iss'] == jwt_issuer
rescue StandardError
false
end
|
#jwt_issuer ⇒ Object
7
8
9
10
11
|
# File 'lib/warden/cognito/jwk_loader.rb', line 7
def jwt_issuer
return "#{user_pool.identifier}-#{jwk.issuer}" if jwk.issuer.present?
"https://cognito-idp.#{user_pool.region}.amazonaws.com/#{user_pool.pool_id}"
end
|