Class: AsyncRequest::JsonWebToken
- Inherits:
-
Object
- Object
- AsyncRequest::JsonWebToken
- Defined in:
- app/poros/async_request/json_web_token.rb
Class Method Summary collapse
- .decode(token) ⇒ Object
- .encode(job_id, expiration = AsyncRequest.config[:token_expiration].to_i) ⇒ Object
Class Method Details
.decode(token) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/poros/async_request/json_web_token.rb', line 17 def self.decode(token) JWT.decode( token, AsyncRequest.config[:decode_key], true, algorithm: AsyncRequest.config[:sign_algorithm] ).first end |
.encode(job_id, expiration = AsyncRequest.config[:token_expiration].to_i) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/poros/async_request/json_web_token.rb', line 6 def self.encode(job_id, expiration = AsyncRequest.config[:token_expiration].to_i) JWT.encode( { job_id: job_id, expires_in: (Time.zone.now + expiration).to_i }, AsyncRequest.config[:encode_key], AsyncRequest.config[:sign_algorithm] ) end |