Class: JWTSignedRequest::Claims

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

Constant Summary collapse

EMPTY_HEADERS =
[].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Claims.



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

def initialize(method:, path:, headers:, body:, additional_headers_to_sign: EMPTY_HEADERS, timeout: DEFAULT_TIMEOUT, issuer:)
  @method = method
  @path = path
  @headers = headers
  @body = body
  @additional_headers_to_sign = additional_headers_to_sign
  @timeout = timeout
  @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



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

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