10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::oidc::AutoDiscovery Class Reference

#include <AutoDiscovery.h>

Detailed Description

Service for querying OIDC configuration from known URL.

Public Member Functions

 AutoDiscovery (std::shared_ptr< const tenduke::http::HTTPClient > httpClient, std::shared_ptr< const tenduke::json::JSONParser > jsonParser, std::shared_ptr< const tenduke::jwk::JWKSParser > jwksParser, std::shared_ptr< const tenduke::time::Clock > clock)
 Constructs new instance.
virtual AutoDiscoveryResult discover (const std::string &url) const
 Performs OIDC configuration auto discovery.
virtual std::string downloadJWKSDocument (const std::string &jwks_uri) const
 Makes HTTP-call to given URL, and downloads the JWKS-document.
virtual std::shared_ptr< const tenduke::oidc::OIDCConfiguration > toOIDCConfiguration (const AutoDiscoveryResult &result) const
 Returns the discovered OIDC-configuration, with a signature validator.
virtual std::unique_ptr< tenduke::jwk::JWKS > getVerificationKeys (const AutoDiscoveryResult &result) const
 Returns the verification keys from tenduke::oauth::oidc::AutoDiscoveryResult.

Constructor & Destructor Documentation

◆ AutoDiscovery()

tenduke::oidc::AutoDiscovery::AutoDiscovery ( std::shared_ptr< const tenduke::http::HTTPClient > httpClient,
std::shared_ptr< const tenduke::json::JSONParser > jsonParser,
std::shared_ptr< const tenduke::jwk::JWKSParser > jwksParser,
std::shared_ptr< const tenduke::time::Clock > clock )

Constructs new instance.

Parameters
httpClient-
jsonParser-
jwksParser-
clockclock for rate limiting the refreshes of the verification keys

Member Function Documentation

◆ discover()

xdoidc::AutoDiscoveryResult tenduke::oidc::AutoDiscovery::discover ( const std::string & url) const
virtual

Performs OIDC configuration auto discovery.

IMPORTANT NOTE:

In current implementation, use AutoDiscovery::toOIDCConfiguration(const AutodiscoveryResult &) to get the full OIDC-configuration including the signature validator, which uses the keys from the JWKS-document.

Parameters
urlfull URL to the discovery document (e.g. https://genco.10duke.com/.well-known/openid-configuration)
Returns
the autodiscovery result
Exceptions
tenduke::crypto::CryptoExceptionif problems with the verification key
tenduke::http::HTTPException(or subclasses of it) when some HTTP-related exception (e.g. malformed URL) occurs
tenduke::json::JSONParsingExceptionwhen server response is not valid JSON
tenduke::oauth::oidc::OIDCExceptionwhen the server response is not what we expected, e.g.
  • HTTP 404 (or other HTTP-error statuses)
  • The response payload is not what is expected
tenduke::net::NetworkingException(or subclasses of it) when networking error occurred, e.g.

◆ downloadJWKSDocument()

std::string tenduke::oidc::AutoDiscovery::downloadJWKSDocument ( const std::string & jwks_uri) const
virtual

Makes HTTP-call to given URL, and downloads the JWKS-document.

Parameters
jwks_uri-
Returns
the JWKS-document. Returns empty string, if jwks_uri was empty.
Exceptions
tenduke::http::HTTPException(or subclasses of it) when some HTTP-related exception (e.g. malformed URL) occurs
tenduke::oauth::oidc::OIDCExceptionwhen the server response is not what we expected, e.g.
  • HTTP 404 (or other HTTP-error statuses)
tenduke::net::NetworkingException(or subclasses of it) when networking error occurred, e.g.

◆ getVerificationKeys()

std::unique_ptr< tenduke::jwk::JWKS > tenduke::oidc::AutoDiscovery::getVerificationKeys ( const AutoDiscoveryResult & result) const
virtual

Returns the verification keys from tenduke::oauth::oidc::AutoDiscoveryResult.

Parameters
result-
Returns
the keys. The vector is empty if the result contains no keys.
Exceptions
tenduke::crypto::CryptoExceptionif problems with the verification key
tenduke::json::JSONParsingExceptionwhen the JWKS-document is not valid JSON
tenduke::jwks::JWKSExceptionwhen the JWKS is not ok

◆ toOIDCConfiguration()

std::shared_ptr< const xdoidc::OIDCConfiguration > tenduke::oidc::AutoDiscovery::toOIDCConfiguration ( const AutoDiscoveryResult & result) const
virtual

Returns the discovered OIDC-configuration, with a signature validator.

This method parses the JWKS-document, and creates a tenduke::jwk::DynamicJWKSSignatureValidator, which selects the key by the "kid" of the ID-token, and refreshes the keys from jwks_uri when it does not know the key (e.g. after the IdP has rotated its keys). The validator always uses the discovered signing algorithm, if supported. To get fully ready OIDCConfiguration, use this method instead of AutoDiscoveryResult::getOOIDCConfiguration().

Parameters
result-
Returns
-
Exceptions
tenduke::crypto::CryptoExceptionif problems with the verification key
tenduke::json::JSONParsingExceptionwhen the JWKS-document is not valid JSON
tenduke::jwks::JWKSExceptionwhen the JWKS is not ok
tenduke::oidc::OIDCExceptionwhen no verification key is found, i.e. the discovery document has no jwks_uri or the JWKS-document has no keys usable for verifying signatures

The documentation for this class was generated from the following files:
  • core/oidc/core/src/oidc/autodiscovery/AutoDiscovery.h
  • core/oidc/core/src/oidc/autodiscovery/AutoDiscovery.cpp