Class: Usps::JwtAuth::Decode
- Inherits:
-
Object
- Object
- Usps::JwtAuth::Decode
- Defined in:
- lib/usps/jwt_auth/decode.rb
Overview
Decode and validate data from a JWT
Class Method Summary collapse
- .decode(token, audience: [], issuer: nil) ⇒ Object
- .token_options(audience: [], issuer: nil) ⇒ Object
Instance Method Summary collapse
Class Method Details
.decode(token, audience: [], issuer: nil) ⇒ Object
8 9 10 |
# File 'lib/usps/jwt_auth/decode.rb', line 8 def self.decode(token, audience: [], issuer: nil) new.decode(token, audience: audience, issuer: issuer) end |
.token_options(audience: [], issuer: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/usps/jwt_auth/decode.rb', line 12 def self.(audience: [], issuer: nil) { required_claims: %w[iss exp], verify_iss: true, verify_aud: true, algorithm: JwtAuth.config.algorithm, aud: audience, iss: /\A#{JwtAuth.config.issuer_base}(?:\z|:#{issuer})/ } end |
Instance Method Details
#decode(token, audience: [], issuer: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/usps/jwt_auth/decode.rb', line 23 def decode(token, audience: [], issuer: nil) result = JWT.decode( token, public_key(token), true, self.class.(audience:, issuer:) ) result[0]['data'] end |