Class: Dpop::ProofGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/dpop/proof_generator.rb

Overview

Generates Proof JWT’s

Defined Under Namespace

Classes: InvalidKeyError, MissingKeyError

Constant Summary collapse

JWT_TYPE =
"dpop+jwt"
RSA =
"RSA"

Instance Method Summary collapse

Constructor Details

#initialize(dpop_key, alg) ⇒ ProofGenerator

Returns a new instance of ProofGenerator.

Raises:



23
24
25
26
27
28
# File 'lib/dpop/proof_generator.rb', line 23

def initialize(dpop_key, alg)
  raise MissingKeyError if dpop_key.blank?

  @dpop_key = dpop_key
  @alg = alg
end

Instance Method Details

#create_dpop_proof(htu:, htm:, nonce: nil, ath: nil, iat: Time.now.to_i, jti: SecureRandom.uuid, **additional) ⇒ Object

Takes the path being called. Returns a signed JWT



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dpop/proof_generator.rb', line 31

def create_dpop_proof(htu:, htm:, nonce: nil, ath: nil, iat: Time.now.to_i, jti: SecureRandom.uuid, **additional)
  private_key, public_key = keys

  headers = create_headers(public_key)

  payload = create_payload(
    htu: htu, htm: htm, ath: ath, iat: iat, jti: jti, nonce: nonce, **additional
  )

  JWT.encode(payload, private_key, @alg, headers)
end