Module: Auth0::ClientAssertion
- Included in:
- Api::AuthenticationEndpoints
- Defined in:
- lib/auth0/client_assertion.rb
Constant Summary collapse
- CLIENT_ASSERTION_TYPE =
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'.freeze
Instance Method Summary collapse
-
#populate_client_assertion_or_secret(hash, domain: @domain, client_id: @client_id, client_secret: @client_secret, client_assertion_signing_key: @client_assertion_signing_key, client_assertion_signing_alg: @client_assertion_signing_alg) ⇒ Object
Adds keys into the supplied hash for either the client secret, or client assertion.
Instance Method Details
#populate_client_assertion_or_secret(hash, domain: @domain, client_id: @client_id, client_secret: @client_secret, client_assertion_signing_key: @client_assertion_signing_key, client_assertion_signing_alg: @client_assertion_signing_alg) ⇒ Object
Adds keys into the supplied hash for either the client secret, or client assertion. If ‘client_assertion_signing_key` is not nil, it takes precedence over `client_secret`.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/auth0/client_assertion.rb', line 16 def populate_client_assertion_or_secret(hash, domain: @domain, client_id: @client_id, client_secret: @client_secret, client_assertion_signing_key: @client_assertion_signing_key, client_assertion_signing_alg: @client_assertion_signing_alg) if !client_assertion_signing_key.nil? # Create JWT now = Time.now.to_i payload = { iss: client_id, sub: client_id, aud: "https://#{domain}/", iat: now, exp: now + 180, jti: SecureRandom.uuid } jwt = JWT.encode payload, client_assertion_signing_key, client_assertion_signing_alg hash[:client_assertion] = jwt hash[:client_assertion_type] = Auth0::ClientAssertion::CLIENT_ASSERTION_TYPE else hash[:client_secret] = client_secret end end |