Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
oauth_metadata.h
1#ifndef SOURCEMETA_CORE_OAUTH_METADATA_H_
2#define SOURCEMETA_CORE_OAUTH_METADATA_H_
3
4#ifndef SOURCEMETA_CORE_OAUTH_EXPORT
5#include <sourcemeta/core/oauth_export.h>
6#endif
7
8#include <sourcemeta/core/json.h>
9
10#include <cstdint> // std::uint8_t
11#include <optional> // std::optional
12#include <span> // std::span
13#include <string> // std::string
14#include <string_view> // std::string_view
15
16namespace sourcemeta::core {
17
35
58SOURCEMETA_CORE_OAUTH_EXPORT
59auto oauth_well_known_url(const std::string_view identifier,
60 const OAuthWellKnownKind kind, std::string &sink)
61 -> bool;
62
79SOURCEMETA_CORE_OAUTH_EXPORT
80auto oauth_is_endpoint_url(const std::string_view value) -> bool;
81
98SOURCEMETA_CORE_OAUTH_EXPORT
99auto oauth_is_resource_identifier(const std::string_view value) -> bool;
100
117SOURCEMETA_CORE_OAUTH_EXPORT
118auto oauth_is_issuer_identifier(const std::string_view value) -> bool;
119
120#if defined(_MSC_VER)
121#pragma warning(disable : 4251)
122#endif
123
152class SOURCEMETA_CORE_OAUTH_EXPORT OAuthServerMetadata {
153public:
156 OAuthServerMetadata(JSON &&data, const std::string_view issuer);
157
160 [[nodiscard]] static auto from(JSON &&data, const std::string_view issuer)
161 -> std::optional<OAuthServerMetadata>;
162
164 [[nodiscard]] auto issuer() const -> std::string_view;
165
167 [[nodiscard]] auto authorization_endpoint() const
168 -> std::optional<std::string_view>;
169
171 [[nodiscard]] auto token_endpoint() const -> std::optional<std::string_view>;
172
174 [[nodiscard]] auto registration_endpoint() const
175 -> std::optional<std::string_view>;
176
178 [[nodiscard]] auto device_authorization_endpoint() const
179 -> std::optional<std::string_view>;
180
182 [[nodiscard]] auto revocation_endpoint() const
183 -> std::optional<std::string_view>;
184
186 [[nodiscard]] auto introspection_endpoint() const
187 -> std::optional<std::string_view>;
188
190 [[nodiscard]] auto jwks_uri() const -> std::optional<std::string_view>;
191
193 [[nodiscard]] auto pushed_authorization_request_endpoint() const
194 -> std::optional<std::string_view>;
195
199 [[nodiscard]] auto require_pushed_authorization_requests() const -> bool;
200
204 -> bool;
205
207 [[nodiscard]] auto supports_response_type(const std::string_view value) const
208 -> bool;
209
212 [[nodiscard]] auto supports_grant_type(const std::string_view value) const
213 -> bool;
214
218 [[nodiscard]] auto
219 supports_code_challenge_method(const std::string_view value) const -> bool;
220
223 [[nodiscard]] auto
224 supports_token_endpoint_auth_method(const std::string_view value) const
225 -> bool;
226
229 [[nodiscard]] auto
230 supports_protected_resource(const std::string_view value) const -> bool;
231
233 [[nodiscard]] auto data() const -> const JSON &;
234
235private:
236 JSON data_;
237};
238
268class SOURCEMETA_CORE_OAUTH_EXPORT OAuthResourceMetadata {
269public:
272 OAuthResourceMetadata(JSON &&data, const std::string_view resource);
273
276 [[nodiscard]] static auto from(JSON &&data, const std::string_view resource)
277 -> std::optional<OAuthResourceMetadata>;
278
280 [[nodiscard]] auto resource() const -> std::string_view;
281
285 [[nodiscard]] auto first_authorization_server() const
286 -> std::optional<std::string_view>;
287
289 [[nodiscard]] auto
290 supports_authorization_server(const std::string_view value) const -> bool;
291
294 [[nodiscard]] auto jwks_uri() const -> std::optional<std::string_view>;
295
299 [[nodiscard]] auto supports_bearer_method(const std::string_view value) const
300 -> bool;
301
303 [[nodiscard]] auto supports_scope(const std::string_view value) const -> bool;
304
307 [[nodiscard]] auto dpop_bound_access_tokens_required() const -> bool;
308
312 [[nodiscard]] auto resource_name() const -> std::optional<std::string_view>;
313
315 [[nodiscard]] auto resource_documentation() const
316 -> std::optional<std::string_view>;
317
319 [[nodiscard]] auto resource_policy_uri() const
320 -> std::optional<std::string_view>;
321
323 [[nodiscard]] auto resource_tos_uri() const
324 -> std::optional<std::string_view>;
325
328 [[nodiscard]] auto tls_client_certificate_bound_access_tokens() const -> bool;
329
332 [[nodiscard]] auto
333 supports_resource_signing_alg(const std::string_view value) const -> bool;
334
337 [[nodiscard]] auto
338 supports_dpop_signing_alg(const std::string_view value) const -> bool;
339
342 [[nodiscard]] auto
343 supports_authorization_details_type(const std::string_view value) const
344 -> bool;
345
348 [[nodiscard]] auto data() const -> const JSON &;
349
350private:
351 JSON data_;
352};
353
354#if defined(_MSC_VER)
355#pragma warning(default : 4251)
356#endif
357
365 std::string_view issuer;
367 std::string_view authorization_endpoint;
369 std::string_view token_endpoint;
371 std::string_view registration_endpoint;
373 std::string_view jwks_uri;
375 std::span<const std::string_view> response_types_supported;
377 std::span<const std::string_view> grant_types_supported;
379 std::span<const std::string_view> code_challenge_methods_supported;
381 std::span<const std::string_view> token_endpoint_auth_methods_supported;
386 std::span<const std::string_view>
389 std::span<const std::string_view> scopes_supported;
400 std::span<const std::string_view> protected_resources;
401};
402
430SOURCEMETA_CORE_OAUTH_EXPORT
432 -> std::optional<JSON>;
433
444 std::string_view resource;
447 std::span<const std::string_view> authorization_servers;
450 std::string_view jwks_uri;
453 std::span<const std::string_view> scopes_supported;
457 std::optional<std::span<const std::string_view>> bearer_methods_supported;
460 std::span<const std::string_view> resource_signing_alg_values_supported;
464 std::string_view resource_name;
466 std::string_view resource_documentation;
468 std::string_view resource_policy_uri;
470 std::string_view resource_tos_uri;
476 std::span<const std::string_view> authorization_details_types_supported;
480 std::span<const std::string_view> dpop_signing_alg_values_supported;
484};
485
511SOURCEMETA_CORE_OAUTH_EXPORT
513 -> std::optional<JSON>;
514
515} // namespace sourcemeta::core
516
517#endif
Definition json_value.h:39
auto supports_authorization_server(const std::string_view value) const -> bool
Whether an authorization server issuer is listed (RFC 9728 Section 2).
auto require_pushed_authorization_requests() const -> bool
auto resource_name() const -> std::optional< std::string_view >
std::span< const std::string_view > authorization_details_types_supported
The supported authorization details types (RFC 9728 Section 2).
Definition oauth_metadata.h:476
auto supports_protected_resource(const std::string_view value) const -> bool
auto resource_documentation() const -> std::optional< std::string_view >
The developer documentation page location (RFC 9728 Section 2).
std::span< const std::string_view > token_endpoint_auth_methods_supported
The supported token endpoint authentication methods (RFC 8414 Section 2).
Definition oauth_metadata.h:381
auto revocation_endpoint() const -> std::optional< std::string_view >
The token revocation endpoint (RFC 8414 Section 2).
auto dpop_bound_access_tokens_required() const -> bool
bool require_pushed_authorization_requests
Definition oauth_metadata.h:397
std::span< const std::string_view > token_endpoint_auth_signing_alg_values_supported
Definition oauth_metadata.h:387
std::string_view resource_policy_uri
The data usage policy page location (RFC 9728 Section 2).
Definition oauth_metadata.h:468
auto data() const -> const JSON &
std::span< const std::string_view > grant_types_supported
The supported grant types (RFC 8414 Section 2).
Definition oauth_metadata.h:377
std::string_view resource_documentation
The developer documentation page location (RFC 9728 Section 2).
Definition oauth_metadata.h:466
auto data() const -> const JSON &
The underlying document, for reaching members without a typed accessor.
auto tls_client_certificate_bound_access_tokens() const -> bool
std::string_view authorization_endpoint
The authorization endpoint (RFC 8414 Section 2).
Definition oauth_metadata.h:367
auto token_endpoint() const -> std::optional< std::string_view >
The token endpoint (RFC 8414 Section 2).
auto registration_endpoint() const -> std::optional< std::string_view >
The dynamic client registration endpoint (RFC 8414 Section 2).
bool tls_client_certificate_bound_access_tokens
Definition oauth_metadata.h:474
auto issuer() const -> std::string_view
The issuer identifier (RFC 8414 Section 2).
auto jwks_uri() const -> std::optional< std::string_view >
auto supports_grant_type(const std::string_view value) const -> bool
auto supports_scope(const std::string_view value) const -> bool
Whether a scope is listed for the resource (RFC 9728 Section 2).
auto introspection_endpoint() const -> std::optional< std::string_view >
The token introspection endpoint (RFC 8414 Section 2).
auto supports_bearer_method(const std::string_view value) const -> bool
auto jwks_uri() const -> std::optional< std::string_view >
The JWK Set document location (RFC 8414 Section 2).
auto resource() const -> std::string_view
The resource identifier (RFC 9728 Section 2).
auto resource_tos_uri() const -> std::optional< std::string_view >
The terms of service page location (RFC 9728 Section 2).
std::span< const std::string_view > response_types_supported
The supported response types (RFC 8414 Section 2), REQUIRED and non-empty.
Definition oauth_metadata.h:375
bool dpop_bound_access_tokens_required
Definition oauth_metadata.h:483
std::string_view jwks_uri
Definition oauth_metadata.h:450
std::span< const std::string_view > authorization_servers
Definition oauth_metadata.h:447
auto supports_code_challenge_method(const std::string_view value) const -> bool
std::string_view resource
The resource identifier (RFC 9728 Section 2), REQUIRED.
Definition oauth_metadata.h:444
auto authorization_endpoint() const -> std::optional< std::string_view >
The authorization endpoint (RFC 8414 Section 2).
std::span< const std::string_view > scopes_supported
Definition oauth_metadata.h:453
std::string_view issuer
The issuer identifier (RFC 8414 Section 2), REQUIRED.
Definition oauth_metadata.h:365
std::string_view jwks_uri
The JWK Set document location (RFC 8414 Section 2).
Definition oauth_metadata.h:373
auto supports_response_type(const std::string_view value) const -> bool
Whether a response type is supported (RFC 8414 Section 2).
OAuthServerMetadata(JSON &&data, const std::string_view issuer)
auto first_authorization_server() const -> std::optional< std::string_view >
static auto from(JSON &&data, const std::string_view issuer) -> std::optional< OAuthServerMetadata >
std::string_view resource_name
Definition oauth_metadata.h:464
std::span< const std::string_view > resource_signing_alg_values_supported
Definition oauth_metadata.h:460
std::string_view registration_endpoint
The dynamic client registration endpoint (RFC 8414 Section 2).
Definition oauth_metadata.h:371
std::string_view pushed_authorization_request_endpoint
Definition oauth_metadata.h:393
auto resource_policy_uri() const -> std::optional< std::string_view >
The data usage policy page location (RFC 9728 Section 2).
auto pushed_authorization_request_endpoint() const -> std::optional< std::string_view >
The pushed authorization request endpoint (RFC 9126 Section 5).
auto authorization_response_iss_parameter_supported() const -> bool
std::string_view token_endpoint
The token endpoint (RFC 8414 Section 2).
Definition oauth_metadata.h:369
auto device_authorization_endpoint() const -> std::optional< std::string_view >
The device authorization endpoint (RFC 8628 Section 4).
auto supports_dpop_signing_alg(const std::string_view value) const -> bool
OAuthResourceMetadata(JSON &&data, const std::string_view resource)
std::string_view resource_tos_uri
The terms of service page location (RFC 9728 Section 2).
Definition oauth_metadata.h:470
std::span< const std::string_view > protected_resources
Definition oauth_metadata.h:400
std::optional< std::span< const std::string_view > > bearer_methods_supported
Definition oauth_metadata.h:457
std::span< const std::string_view > code_challenge_methods_supported
The supported PKCE code challenge methods (RFC 8414 Section 2, RFC 7636).
Definition oauth_metadata.h:379
auto supports_authorization_details_type(const std::string_view value) const -> bool
static auto from(JSON &&data, const std::string_view resource) -> std::optional< OAuthResourceMetadata >
auto supports_token_endpoint_auth_method(const std::string_view value) const -> bool
std::span< const std::string_view > dpop_signing_alg_values_supported
Definition oauth_metadata.h:480
auto supports_resource_signing_alg(const std::string_view value) const -> bool
std::span< const std::string_view > scopes_supported
The supported scopes (RFC 8414 Section 2).
Definition oauth_metadata.h:389
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_server_metadata(const OAuthServerMetadataConfig &config) -> std::optional< JSON >
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_is_resource_identifier(const std::string_view value) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_resource_metadata(const OAuthResourceMetadataConfig &config) -> std::optional< JSON >
OAuthWellKnownKind
Definition oauth_metadata.h:21
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_is_endpoint_url(const std::string_view value) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_is_issuer_identifier(const std::string_view value) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_well_known_url(const std::string_view identifier, const OAuthWellKnownKind kind, std::string &sink) -> bool
@ OpenIDConfigurationAppended
Definition oauth_metadata.h:33
@ AuthorizationServer
Definition oauth_metadata.h:24
@ OpenIDConfigurationInserted
Definition oauth_metadata.h:30
@ ProtectedResource
Definition oauth_metadata.h:27
Definition oauth_metadata.h:442
Definition oauth_metadata.h:363