Sha256: 4ce0ca53cdfdd5da66d71e59c4627a87fc3dd725c053d3ba6643808141e529e5

Contents?: true

Size: 655 Bytes

Versions: 10

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

module Warden
  module JWTAuth
    # Decodes a JWT into a hash payload into a JWT token
    class TokenDecoder
      include JWTAuth::Import['secret']

      # Decodes the payload from a JWT as a hash
      #
      # @see JWT.decode for all the exceptions than can be raised when given
      # token is invalid
      #
      # @param token [String] a JWT
      # @return [Hash] payload decoded from the JWT
      def call(token)
        JWT.decode(token,
                   secret,
                   true,
                   algorithm: TokenEncoder::ALG,
                   verify_jti: true)[0]
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
warden-jwt_auth-0.3.6 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.3.5 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.3.4 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.3.3 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.3.2 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.3.1 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.3.0 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.2.1 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.2.0 lib/warden/jwt_auth/token_decoder.rb
warden-jwt_auth-0.1.4 lib/warden/jwt_auth/token_decoder.rb