Class: ADAL::SelfSignedJwtFactory

Inherits:
Object
  • Object
show all
Includes:
JwtParameters, Logging
Defined in:
lib/adal/self_signed_jwt_factory.rb

Overview

Converts client certificates into self signed JWTs.

Constant Summary

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::DEFAULT_LOG_OUTPUT

Constants included from JwtParameters

JwtParameters::ALGORITHM, JwtParameters::AUDIENCE, JwtParameters::EXPIRES_ON, JwtParameters::ISSUER, JwtParameters::JWT_ID, JwtParameters::NOT_BEFORE, JwtParameters::RS256, JwtParameters::SELF_SIGNED_JWT_LIFETIME, JwtParameters::SUBJECT, JwtParameters::THUMBPRINT, JwtParameters::TYPE, JwtParameters::TYPE_JWT

Instance Method Summary collapse

Methods included from Logging

#logger

Constructor Details

#initialize(client_id, token_endpoint) ⇒ SelfSignedJwtFactory

Constructs a new SelfSignedJwtFactory.

Parameters:

  • String

    client_id The client id of the calling application.

  • String

    token_endpoint The token endpoint that will accept the certificate.



43
44
45
46
# File 'lib/adal/self_signed_jwt_factory.rb', line 43

def initialize(client_id, token_endpoint)
  @client_id = client_id
  @token_endpoint = token_endpoint
end

Instance Method Details

#create_and_sign_jwt(certificate, private_key) ⇒ Object

Creates a JWT from a client certificate and signs it with a private key.

Parameters:

  • OpenSSL::X509::Certificate

    certificate The certifcate object to be converted to a JWT and signed for use in an authentication flow.

  • OpenSSL::PKey::RSA

    private_key The private key used to sign the certificate.

Returns:

  • String



57
58
59
# File 'lib/adal/self_signed_jwt_factory.rb', line 57

def create_and_sign_jwt(certificate, private_key)
  JWT.encode(payload, private_key, RS256, header(certificate))
end