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.



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

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



9
10
11
# File 'lib/jwt_signed_request/claims.rb', line 9

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

Instance Method Details

#generateObject



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

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