Module: JwtBouncer::SignRequest
- Defined in:
- lib/jwt_bouncer/sign_request.rb
Class Method Summary collapse
- .call(request, **options) ⇒ Object
- .generate_token(permissions: {}, actor: {}, account_reference:, shared_secret:, expiry: nil) ⇒ Object
Class Method Details
.call(request, **options) ⇒ Object
7 8 9 10 |
# File 'lib/jwt_bouncer/sign_request.rb', line 7 def self.call(request, **) request.headers['Authorization'] = "Bearer #{generate_token(**)}" request end |
.generate_token(permissions: {}, actor: {}, account_reference:, shared_secret:, expiry: nil) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/jwt_bouncer/sign_request.rb', line 12 def self.generate_token(permissions: {}, actor: {}, account_reference:, shared_secret:, expiry: nil) payload = { permissions: Permissions.compress(), actor: actor, account_reference: account_reference } Token.encode(payload, shared_secret, expiry: expiry) end |