Sha256: 85eabb0f2730617c3937e75fc88d44b58dedb367175b5709f99c1e0dbb4fb3a4
Contents?: true
Size: 649 Bytes
Versions: 1
Compression:
Stored size: 649 Bytes
Contents
module MaticJWT class Authenticator def initialize(headers) @token = extract_token(headers) 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(headers) header = headers['Authorization'] validate_header_presence!(header) header.slice(8..-1) end def payload JWT.decode(@token, nil, false) end def validate_header_presence!(header) raise(JWT::DecodeError, 'Authorization header is missing') if header.nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
matic-jwt-0.2.4 | lib/matic-jwt/authenticator.rb |