10Duke Scale C++ Client
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)
 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::OIDCConfigurationtoOIDCConfiguration (const AutoDiscoveryResult &result) const
 Returns the discovered OIDC-configuration, with default verification key.
 
virtual std::unique_ptr< tenduke::jwk::JWKSgetVerificationKeys (const AutoDiscoveryResult &result) const
 Returns the verification keys from tenduke::oauth::oidc::AutoDiscoveryResult.
 
virtual std::unique_ptr< const tenduke::jwk::JWKgetDefaultVerificationKey (const AutoDiscoveryResult &result) const
 Returns the default verification key 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 
)

Constructs new instance.

Parameters
httpClient-
jsonParser-
jwksParser-

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 verification key, which is parsed 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.

◆ getDefaultVerificationKey()

std::unique_ptr< const xdjwk::JWK > tenduke::oidc::AutoDiscovery::getDefaultVerificationKey ( const AutoDiscoveryResult result) const
virtual

Returns the default verification key from tenduke::oauth::oidc::AutoDiscoveryResult.

This implementation returns first key from the JWKS "keys"-array (or nullptr if there is no JWKS-document or the "keys" array is empty).

Parameters
result-
Returns
the default verification key. Returns nullptr if the result has 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

◆ 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 default verification key.

This method parses the JWKS-document and extracts the default verification key. To get fully ready OIDCConfiguration, use this method instead of AutoDiscoveryResult::toOIDCConfiguration().

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

The documentation for this class was generated from the following files: