Module: RailsJwtAuth::JwtManager
- Defined in:
- lib/rails_jwt_auth/jwt_manager.rb
Class Method Summary collapse
-
.decode(token) ⇒ Object
Decodes the JWT with the signed secret [“exp”=>148…, “iss”=>“RJA”, “alg”=>“HS256”].
-
.encode(payload) ⇒ Object
Encodes and signs JWT Payload with expiration.
-
.meta ⇒ Object
Default options to be encoded in the token.
- .secret_key_base ⇒ Object
Class Method Details
.decode(token) ⇒ Object
Decodes the JWT with the signed secret
- “exp”=>148…, “iss”=>“RJA”, “alg”=>“HS256”
19 20 21 |
# File 'lib/rails_jwt_auth/jwt_manager.rb', line 19 def self.decode(token) JWT.decode(token, secret_key_base) end |
.encode(payload) ⇒ Object
Encodes and signs JWT Payload with expiration
10 11 12 13 14 15 |
# File 'lib/rails_jwt_auth/jwt_manager.rb', line 10 def self.encode(payload) raise InvalidJwtPayload unless payload payload.reverse_merge!() JWT.encode(payload, secret_key_base) end |
.meta ⇒ Object
Default options to be encoded in the token
24 25 26 27 28 29 |
# File 'lib/rails_jwt_auth/jwt_manager.rb', line 24 def self. { exp: RailsJwtAuth.jwt_expiration_time.from_now.to_i, iss: RailsJwtAuth.jwt_issuer } end |
.secret_key_base ⇒ Object
5 6 7 |
# File 'lib/rails_jwt_auth/jwt_manager.rb', line 5 def self.secret_key_base Rails.application.secrets.secret_key_base || Rails.application.credentials.secret_key_base end |