1#ifndef TENDUKE_EE_BASECLIENTFACTORY_H
2#define TENDUKE_EE_BASECLIENTFACTORY_H
4#include "./createTendukeClient.h"
5#include "./TendukeClient.h"
6#include "./config/ClientProperties.h"
7#include "./state/DeserializeStateFromJSON.h"
8#include "createDefaultTendukeServices.h"
9#include "ServiceConfiguration.h"
10#include "TendukeServices.h"
12#include "oidc/session/OIDCLogin.h"
17namespace tenduke {
namespace ee {
39 const std::string &clientId,
68 virtual std::unique_ptr<::tenduke::ee::TendukeClient>
createClient(
69 const ::tenduke::ee::ClientProperties &clientProperties,
70 const std::string &serviceUrl,
71 const ::tenduke::oauth::OAuthBackendConfiguration &oauthBackendConfiguration,
72 const ::tenduke::oidc::OIDCConfiguration &oidcConfiguration,
73 const P &authenticationConfiguration,
74 const std::string &initialStateAsJSON = {}
77 auto oauthConfiguration =
mkOAuthConfiguration(oauthBackendConfiguration, authenticationConfiguration);
78 auto oidcConfig = std::shared_ptr<::tenduke::oidc::OIDCConfiguration>(new ::tenduke::oidc::OIDCConfiguration(oidcConfiguration));
80 return ::tenduke::ee::createClient(
86 authenticationConfiguration.oidcSessionConfiguration,
106 const ::tenduke::ee::ClientProperties &clientProperties,
107 const std::string &serviceUrl,
108 const P &authenticationConfiguration,
109 const std::string &initialStateAsJSON = {}
113 auto discoveryResult = services.
oidcBackendConfiguration->discover(serviceUrl +
"/.well-known/openid-configuration");
115 auto oauthConfiguration =
mkOAuthConfiguration(*discoveryResult.getOAuthConfiguration(), authenticationConfiguration);
119 return ::tenduke::ee::createClient(
125 authenticationConfiguration.oidcSessionConfiguration,
139 const std::shared_ptr<const ::tenduke::oauth::OAuthConfiguration> &oauthConfig,
140 const std::shared_ptr<const ::tenduke::oidc::OIDCConfiguration> &oidcConfig,
141 const P &authenticationConfig
151 const ::tenduke::oauth::OAuthBackendConfiguration &oauthBackendConfig,
152 const P &authenticationConfig
164 const std::string &serviceUrl,
165 const ::tenduke::ee::ClientProperties &clientProperties,
166 const ::tenduke::oidc::OIDCConfiguration &oidcConfig
169 return std::make_shared<::tenduke::ee::licensing::LicensingConfiguration>(
170 serviceUrl +
"/authz/",
172 oidcConfig.verificationKey,
173 oidcConfig.digestAlgorithm
183 const ::tenduke::oidc::AutoDiscovery &service,
184 const ::tenduke::oidc::AutoDiscoveryResult &result
188 ::tenduke::log::debug(
" - authorization endpoint: " + result.getOAuthConfiguration()->authorizationEndpointUrl);
194 auto jwk = service.getDefaultVerificationKey(result);
Configuration for supporting services.
Definition ServiceConfiguration.h:12
A "service locator" for core services used by Tenduke client.
Definition TendukeServices.h:26
const std::shared_ptr< const tenduke::json::JSONParser > jsonParser
JSON-parser.
Definition TendukeServices.h:72
const std::shared_ptr< const tenduke::jwt::JWTParserFactory > jwtParser
JWT-parser factory.
Definition TendukeServices.h:74
const std::shared_ptr< const tenduke::oidc::AutoDiscovery > oidcBackendConfiguration
OIDC configuration auto discovery service.
Definition TendukeServices.h:78
Class template for factories, which create 10Duke client.
Definition AbstractClientFactory.h:26
virtual std::shared_ptr<::tenduke::oidc::OIDCLogin > createOIDCLoginService(const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > &oauthConfig, const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > &oidcConfig, const P &authenticationConfig) const =0
Creates the authentication-specific OIDC login service.
std::unique_ptr<::tenduke::ee::TendukeClient > createClientUsingAutodiscovery(const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const P &authenticationConfiguration, const std::string &initialStateAsJSON={}) const
Creates client for 10Duke Enterprise, using OIDC autodiscovery for OAuth and OIDC parameters.
Definition AbstractClientFactory.h:105
AbstractClientFactory(const ::tenduke::TendukeServices &services)
Constructs new instance with given services.
Definition AbstractClientFactory.h:51
virtual std::unique_ptr<::tenduke::ee::TendukeClient > createClient(const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oauth::OAuthBackendConfiguration &oauthBackendConfiguration, const ::tenduke::oidc::OIDCConfiguration &oidcConfiguration, const P &authenticationConfiguration, const std::string &initialStateAsJSON={}) const
Creates client for 10Duke Enterprise from manually provided parameters.
Definition AbstractClientFactory.h:68
AbstractClientFactory(const std::string &clientId, const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
Constructs new instance with default services.
Definition AbstractClientFactory.h:38
virtual std::shared_ptr<::tenduke::ee::licensing::LicensingConfiguration > mkLicensingConfiguration(const std::string &serviceUrl, const ::tenduke::ee::ClientProperties &clientProperties, const ::tenduke::oidc::OIDCConfiguration &oidcConfig) const
Creates licensing configuration from provided parameters.
Definition AbstractClientFactory.h:163
virtual std::shared_ptr<::tenduke::oauth::OAuthConfiguration > mkOAuthConfiguration(const ::tenduke::oauth::OAuthBackendConfiguration &oauthBackendConfig, const P &authenticationConfig) const =0
Creates full OAuth-configuration.
virtual void dumpAutodiscoveryResult(const ::tenduke::oidc::AutoDiscovery &service, const ::tenduke::oidc::AutoDiscoveryResult &result) const
Dumps OIDC autodiscovery result to log, using DEBUG log level.
Definition AbstractClientFactory.h:182
Service for deserializing client state from JSON.
Definition DeserializeStateFromJSON.h:17
::tenduke::ee::ClientState from(const std::string &stateSerializedAsJSON) const
Deserializes the state from JSON.
Definition DeserializeStateFromJSON.cpp:76
void debug(const char *message)
Write message to global logger at DEBUG-level.
Definition log.cpp:26
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4
tenduke::TendukeServices createDefaultTendukeServices(const std::string &clientId, const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
Creates the default services used by Tenduke client.
Definition createDefaultTendukeServices.cpp:27