Module: JwtBouncer::SignRequest

Defined in:
lib/jwt_bouncer/sign_request.rb

Class Method Summary collapse

Class Method Details

.call(request, **options) ⇒ Object



7
8
9
10
# File 'lib/jwt_bouncer/sign_request.rb', line 7

def self.call(request, **options)
  request.headers['Authorization'] = "Bearer #{generate_token(**options)}"
  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(permissions),
    actor: actor,
    account_reference: 
  }
  Token.encode(payload, shared_secret, expiry: expiry)
end