Class: JWTea::Token
- Inherits:
-
Object
- Object
- JWTea::Token
- Defined in:
- lib/jw_tea/token.rb,
lib/jw_tea/token/payload.rb
Defined Under Namespace
Classes: Payload
Instance Attribute Summary collapse
-
#encoded ⇒ Object
Returns the value of attribute encoded.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(payload) ⇒ Token
constructor
A new instance of Token.
-
#inspect ⇒ Object
Prevent sentitive data from being accidentally logged to console.
Constructor Details
Instance Attribute Details
#encoded ⇒ Object
Returns the value of attribute encoded.
20 21 22 |
# File 'lib/jw_tea/token.rb', line 20 def encoded @encoded end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
21 22 23 |
# File 'lib/jw_tea/token.rb', line 21 def payload @payload end |
Class Method Details
.build(data, exp, secret, algorithm) ⇒ Object
13 14 15 16 17 |
# File 'lib/jw_tea/token.rb', line 13 def build(data, exp, secret, algorithm) token = new(data: data, exp: exp) token.encoded = ::JWT.encode(token.payload.to_h, secret, algorithm) token end |
.load(encoded_token, secret, algorithm) ⇒ Object
8 9 10 11 |
# File 'lib/jw_tea/token.rb', line 8 def load(encoded_token, secret, algorithm) payload, _header = ::JWT.decode(encoded_token, secret, true, verify_iat: true, algorithm: algorithm) new(payload) end |
Instance Method Details
#inspect ⇒ Object
Prevent sentitive data from being accidentally logged to console
29 30 31 |
# File 'lib/jw_tea/token.rb', line 29 def inspect to_s end |