Class: LightJWT::JWSHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- LightJWT::JWSHandler
- Defined in:
- lib/light_jwt/jwt.rb
Instance Method Summary collapse
Methods inherited from BaseHandler
Instance Method Details
#decode(input, key, options) ⇒ Object
66 67 68 69 70 |
# File 'lib/light_jwt/jwt.rb', line 66 def decode(input, key, ) jws = JWS.decode_compact_serialized(input, key) jws.verify! unless [:skip_verification] jws end |
#sign(claims, alg, signing_key) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/light_jwt/jwt.rb', line 59 def sign(claims, alg, signing_key) jose_header = { alg:, typ: 'JWT' } token = [jose_header, claims].map { |segment| base64_encode(segment) }.join('.') jws = JWS.new(token, alg, signing_key) jws.sign! end |