Module: Rails::Vault::JWT::Decoder
- Defined in:
- lib/rails/vault/jwt/decoder.rb
Class Method Summary collapse
Class Method Details
.decode(token) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rails/vault/jwt/decoder.rb', line 12 def decode(token) HashWithIndifferentAccess.new(::JWT.decode( token, nil, true, { algorithms: ['RS256', 'RS512'], jwks: key_provider.keys(issuer(token)) } )[0]) rescue StandardError => e JWT.config.logger.error "Error while decoding token: #{e}" nil end |
.issuer(token) ⇒ Object
27 28 29 30 31 |
# File 'lib/rails/vault/jwt/decoder.rb', line 27 def issuer(token) parts = token.split('.') body = HashWithIndifferentAccess.new(JSON.parse(Base64.decode64(parts[1]))) body[:iss] end |
.key_provider ⇒ Object
33 34 35 |
# File 'lib/rails/vault/jwt/decoder.rb', line 33 def key_provider @key_provider ||= KeyProvider.new end |