Class: JWTSignedRequest::Claims

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt_signed_request/claims.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, headers:, body:, additional_headers_to_sign:, issuer:) ⇒ Claims

Returns a new instance of Claims.



11
12
13
14
15
16
17
18
# File 'lib/jwt_signed_request/claims.rb', line 11

def initialize(method:, path:, headers:, body:, additional_headers_to_sign:, issuer:)
  @method = method
  @path = path
  @headers = headers || EMPTY_HEADERS
  @body = body
  @additional_headers_to_sign = additional_headers_to_sign || EMPTY_HEADERS
  @issuer = issuer
end

Class Method Details

.generate(args) ⇒ Object



7
8
9
# File 'lib/jwt_signed_request/claims.rb', line 7

def self.generate(args)
  new(**args).generate
end

Instance Method Details

#generateObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jwt_signed_request/claims.rb', line 22

def generate
  result = {
    method: method,
    path: path,
    headers: serialized_headers,
    body_sha: body_sha,
    exp: (Time.now + timeout).to_i
  }
  result[:iss] = issuer if issuer
  result
end