Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Configuration.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_Auth_OAuth_Configuration_h_
5#define _Stroika_Frameworks_Auth_OAuth_Configuration_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Common/Common.h"
11#include "Stroika/Foundation/Common/GUID.h"
12#include "Stroika/Foundation/Containers/KeyedCollection.h"
13#include "Stroika/Foundation/Containers/Sequence.h"
14#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
16
17/**
18 * \file
19 *
20 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
21 */
22
23namespace Stroika::Frameworks::Auth::OAuth {
24
25 using namespace Stroika::Foundation;
26
30 using Containers::Set;
31 using IO::Network::URI;
32
34
35 /**
36 * Documentation about these concepts:
37 * google - https://developers.google.com/identity/protocols/oauth2/web-server#httprest
38 * - https://developers.google.com/identity/protocols/oauth2/javascript-implicit-flow
39 */
40
41 /**
42 * Documentation where to get/register application IDs
43 * google - https://console.cloud.google.com/apis/credentials
44 * azure - https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade
45 * - https://learn.microsoft.com/en-us/azure/active-directory-b2c/client-credentials-grant-flow?pivots=b2c-user-flow#app-registration-overview
46 */
47
48 /**
49 * \brief sometimes called ClientID, and sometimes called applicationID
50 *
51 * \note though this is often a GUID, it cannot be assumed to be a GUID (google for example, doesn't use GUIDs).
52 */
54
55 /**
56 * often require things like no #/fragments
57 */
59
60 /**
61 * \brief Track configuration data about stuff that differentiates different
62 * OAuth providers - what URLs to use, base url, relative off that URLs for login/upgrade token/refresh etc.
63 * ALL very prelim at this stage.
64 *
65 * see javascript frameworks - for doing auth2 - convert token to access token etc...
66 * stuff to fetch 'keys' like I vaguely remember from openid... to validate JWTs...\
67 *
68 *
69 *
70 * @todo - create API structure so can fill in details on this via fetch of https://accounts.google.com/.well-known/openid-configuration
71 * read docs on that - and meaning of various parts - and list here etc...
72 *
73 * probably use more optional<URI> on these....
74 */
76 public:
77 /**
78 * name used to join between ProviderConfiguration and ClientConfiguration::fProvider
79 */
81
82 /**
83 * EG https://accounts.google.com/.well-known/openid-configuration
84 * https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration
85 * https://account.apple.com/.well-known/openid-configuration
86 * https://www.facebook.com/.well-known/openid-configuration
87 * https://dev-84941762.okta.com/.well-known/openid-configuration?client_id=0oa5km1v306LXN57y5d7
88 *
89 * \see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
90 * \see https://openid.net/specs/openid-connect-rpinitiated-1_0.html
91 *
92 * \note - this ID may or may not end in '/.well-known/openid-configuration'; however, even if it
93 * doesn't, that is implicitly appended before fetching the configuration data.
94 */
96
97 /**
98 * Same as authorization_endpoint from openid_configuration_uri
99 */
100 optional<URI> auth_uri;
101
102 /**
103 * Same as token_endpoint from openid_configuration_uri
104 * \note facebook doesn't appear to support this - so I guess just use id_token and (what flow)???
105 */
106 optional<URI> token_uri;
107
108 /**
109 * if missing, try FetchAdditionsFromOpenIDConfigurationURI (), or hopefully get id_token from GetToken() api.
110 */
111 optional<URI> userinfo_endpoint;
112
113 /**
114 * GOOGLE uses this but I cannot find docs - https://accounts.google.com/.well-known/openid-configuration
115 */
116 optional<URI> revocation_endpoint;
117
118 /**
119 * Same as jwks_uri from openid_configuration_uri
120 */
122
123 /**
124 * Fetch the data from the openid_configuration_uri, and use it to augment the fields
125 * of this structure, and return the updated record (replacing items that conflict).
126 *
127 * This can be used to fill in a Provider configuration when all you have is the URL for openid-configuration
128 *
129 * \par Example Usage
130 * \code
131 * ProviderConfiguration providerConfig =
132 * ProviderConfiguration{.name = "MyOKTAAccount", .openid_configuration_uri = "https://dev-84941762.okta.com/.well-known/openid-configuration?client_id=0oa5km1v306LXN57y5d7"}
133 * .FetchAdditionsFromOpenIDConfigurationURI ();
134 * \endcode
135 */
137
138 /**
139 */
140 nonvirtual bool operator== (const ProviderConfiguration& rhs) const = default;
141
142#if qCompilerAndStdLib_explicitly_defaulted_threeway_warning_Buggy
143 DISABLE_COMPILER_CLANG_WARNING_START ("clang diagnostic ignored \"-Wdefaulted-function-deleted\"")
144#endif
145 /**
146 */
147 nonvirtual auto operator<=> (const ProviderConfiguration& rhs) const = default;
148
149#if qCompilerAndStdLib_explicitly_defaulted_threeway_warning_Buggy
150 DISABLE_COMPILER_CLANG_WARNING_END ("clang diagnostic ignored \"-Wdefaulted-function-deleted\"")
151#endif
152
153 static const ObjectVariantMapper kMapper;
154
155 nonvirtual String ToString () const;
156 };
157
158 namespace Private_ {
159 using My_Extractor_ = decltype ([] (const ProviderConfiguration& t) -> String { return t.name; });
161 }
162 /**
163 * A list of definitions for configurations.
164 *
165 * @todo provide predefined one inside this framework, and allow it to be updated/revised in applications.
166 * REFERENED IMPLICITLY in ClientConfiguration
167 */
169
170 /**
171 * a predefined set of configurations, but you may need to update/roll your own, as this could get out of date.
172 */
174
175 /**
176 * \note logically, we want to aggregate ProviderConfiguration inside ClientConfiguration, but
177 * since it can generally be static and unchanged, we keep it separate, and just link up/reference by 'name'
178 */
180 String fProvider; // refers to some element of ProvidersConfigurationType
181
182 /**
183 * This value is sometimes referred to in OAUTH as ClientID
184 */
186
187 /**
188 * List of acceptable redirect URLs allowed in (which flows) authorization_code acquisition; only one will be actually used
189 * in the authentication_code request.
190 */
192
193 /**
194 * List of acceptable scopes requested. Some subset (often all) will be requested at in the authentication_code request.
195 */
197
198 /**
199 * This is used in some places, and must be hidden in others (so optional).
200 */
201 optional<String> fClientSecret;
202
203 static const ObjectVariantMapper kMapper;
204
205 /**
206 */
207 nonvirtual bool operator== (const ClientConfiguration& rhs) const = default;
208
209 /**
210 */
211 nonvirtual auto operator<=> (const ClientConfiguration& rhs) const;
212
213 /**
214 */
215 nonvirtual String ToString () const;
216 };
217
218 /**
219 * \par Example Usage
220 * \code
221 * {
222 * { .fProvider = "google", .fApplicationID = "003...", .fRedirectURLs = ["http://localhost"], .fScopes = ["openid"] },
223 * { .fProvider = "apple", .fApplicationID = "003...", .fRedirectURLs = ["http://localhost"], .fScopes = ["openid"] },
224 * { .fProvider = "twitter", .fApplicationID = "003...", .fRedirectURLs = ["http://localhost"], .fScopes = ["openid"] },
225 * { .fProvider = "facebook", .fApplicationID = "003...", .fRedirectURLs = ["http://localhost"], .fScopes = ["openid"] },
226 * }
227 * \endcode
228 */
230
231}
232
233/*
234 ********************************************************************************
235 ***************************** Implementation Details ***************************
236 ********************************************************************************
237 */
238#include "Configuration.inl"
239
240#endif /*_Stroika_Frameworks_Auth_OAuth_Configuration_h_*/
const ProvidersConfigurations kDefaultProviderConfigurations
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
a cross between Mapping<KEY, T> and Collection<T> and Set<T>
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
Set<T> is a container of T, where once an item is added, additionally adds () do nothing.
Definition Set.h:105
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
Track configuration data about stuff that differentiates different OAuth providers - what URLs to use...
nonvirtual ProviderConfiguration FetchAdditionsFromOpenIDConfigurationURI() const