Sha256: e9a92bd9e7312d7fadaf61e627312738c762e3c11746e2f13b80250ac0b4bb4d
Contents?: true
Size: 686 Bytes
Versions: 1
Compression:
Stored size: 686 Bytes
Contents
module MaticJWT class Authenticator TOKEN_TYPE = 'Bearer: '.freeze def initialize(header) @token = extract_token(header) end def client_name payload.first['client_name'] end def authenticate_with_secret!(secret) JWT.decode(@token, secret, true, algorithm: ALGORITHM) end private def extract_token(header) token = header.slice(TOKEN_TYPE.length..-1) validate_header_presence!(token) token end def payload JWT.decode(@token, nil, false) end def validate_header_presence!(token) raise(JWT::DecodeError, 'Authorization token is incorrect') unless token&.present? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
matic-jwt-0.3.0 | lib/matic-jwt/authenticator.rb |