Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
oauth_registration.h
1#ifndef SOURCEMETA_CORE_OAUTH_REGISTRATION_H_
2#define SOURCEMETA_CORE_OAUTH_REGISTRATION_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 <chrono> // std::chrono::seconds
11#include <optional> // std::optional
12#include <span> // std::span
13#include <string_view> // std::string_view
14
15namespace sourcemeta::core {
16
17#if defined(_MSC_VER)
18#pragma warning(disable : 4251)
19#endif
20
53class SOURCEMETA_CORE_OAUTH_EXPORT OAuthClientMetadata {
54public:
58
61 [[nodiscard]] static auto from(JSON &&data)
62 -> std::optional<OAuthClientMetadata>;
63
65 [[nodiscard]] auto has_redirect_uri(const std::string_view value) const
66 -> bool;
67
70 [[nodiscard]] auto token_endpoint_auth_method() const -> std::string_view;
71
74 [[nodiscard]] auto supports_grant_type(const std::string_view value) const
75 -> bool;
76
79 [[nodiscard]] auto supports_response_type(const std::string_view value) const
80 -> bool;
81
83 [[nodiscard]] auto client_name() const -> std::optional<std::string_view>;
84
86 [[nodiscard]] auto client_uri() const -> std::optional<std::string_view>;
87
89 [[nodiscard]] auto logo_uri() const -> std::optional<std::string_view>;
90
92 [[nodiscard]] auto scope() const -> std::optional<std::string_view>;
93
95 [[nodiscard]] auto has_contact(const std::string_view value) const -> bool;
96
98 [[nodiscard]] auto tos_uri() const -> std::optional<std::string_view>;
99
101 [[nodiscard]] auto policy_uri() const -> std::optional<std::string_view>;
102
104 [[nodiscard]] auto jwks_uri() const -> std::optional<std::string_view>;
105
108 [[nodiscard]] auto software_id() const -> std::optional<std::string_view>;
109
111 [[nodiscard]] auto software_version() const
112 -> std::optional<std::string_view>;
113
116 [[nodiscard]] auto software_statement() const
117 -> std::optional<std::string_view>;
118
121 [[nodiscard]] auto client_id() const -> std::optional<std::string_view>;
122
125 [[nodiscard]] auto client_secret() const -> std::optional<std::string_view>;
126
129 [[nodiscard]] auto client_id_issued_at() const
130 -> std::optional<std::chrono::seconds>;
131
134 [[nodiscard]] auto client_secret_expires_at() const
135 -> std::optional<std::chrono::seconds>;
136
139 [[nodiscard]] auto registration_access_token() const
140 -> std::optional<std::string_view>;
141
144 [[nodiscard]] auto registration_client_uri() const
145 -> std::optional<std::string_view>;
146
148 [[nodiscard]] auto data() const -> const JSON &;
149
150private:
151 JSON data_;
152};
153
154#if defined(_MSC_VER)
155#pragma warning(default : 4251)
156#endif
157
165 std::span<const std::string_view> redirect_uris;
170 std::span<const std::string_view> grant_types;
172 std::span<const std::string_view> response_types;
174 std::string_view client_name;
176 std::string_view client_uri;
178 std::string_view logo_uri;
180 std::string_view scope;
182 std::span<const std::string_view> contacts;
184 std::string_view tos_uri;
186 std::string_view policy_uri;
189 std::string_view jwks_uri;
193 const JSON *jwks{nullptr};
195 std::string_view software_id;
197 std::string_view software_version;
199 std::string_view software_statement;
200};
201
226[[nodiscard]] SOURCEMETA_CORE_OAUTH_EXPORT auto
228 -> std::optional<JSON>;
229
246[[nodiscard]] SOURCEMETA_CORE_OAUTH_EXPORT auto
247oauth_make_registration_error_response(const std::string_view error,
248 const std::string_view error_description)
249 -> JSON;
250
275[[nodiscard]] SOURCEMETA_CORE_OAUTH_EXPORT auto
277 const OAuthClientMetadata &metadata) -> bool;
278
305[[nodiscard]] SOURCEMETA_CORE_OAUTH_EXPORT auto
307 -> bool;
308
317 std::string_view client_id;
320 std::string_view client_secret;
322 std::optional<std::chrono::seconds> client_id_issued_at{};
325 std::optional<std::chrono::seconds> client_secret_expires_at{};
332 std::string_view registration_client_uri;
333};
334
360[[nodiscard]] SOURCEMETA_CORE_OAUTH_EXPORT auto
362 const OAuthClientRegistrationResult &result)
363 -> std::optional<JSON>;
364
392[[nodiscard]] SOURCEMETA_CORE_OAUTH_EXPORT auto
394 const OAuthClientRegistrationConfig &config,
395 const std::string_view client_id, const std::string_view client_secret)
396 -> std::optional<JSON>;
397
398} // namespace sourcemeta::core
399
400#endif
Definition json_value.h:39
std::string_view client_uri
The client information page (RFC 7591 Section 2).
Definition oauth_registration.h:176
std::string_view jwks_uri
Definition oauth_registration.h:189
auto supports_response_type(const std::string_view value) const -> bool
std::span< const std::string_view > contacts
The ways to contact those responsible for the client (RFC 7591 Section 2).
Definition oauth_registration.h:182
std::string_view policy_uri
The privacy policy page (RFC 7591 Section 2).
Definition oauth_registration.h:186
auto data() const -> const JSON &
The underlying document, for reaching members without a typed accessor.
auto logo_uri() const -> std::optional< std::string_view >
The client logo location (RFC 7591 Section 2).
auto has_redirect_uri(const std::string_view value) const -> bool
Whether a redirection URI is registered (RFC 7591 Section 2).
std::string_view registration_client_uri
Definition oauth_registration.h:332
std::string_view software_version
The client software version (RFC 7591 Section 2).
Definition oauth_registration.h:197
static auto from(JSON &&data) -> std::optional< OAuthClientMetadata >
auto client_secret() const -> std::optional< std::string_view >
auto client_secret_expires_at() const -> std::optional< std::chrono::seconds >
std::span< const std::string_view > redirect_uris
Definition oauth_registration.h:165
std::string_view software_id
The client software identifier (RFC 7591 Section 2).
Definition oauth_registration.h:195
std::string_view logo_uri
The client logo location (RFC 7591 Section 2).
Definition oauth_registration.h:178
std::optional< std::chrono::seconds > client_id_issued_at
The time the client identifier was issued (RFC 7591 Section 3.2.1).
Definition oauth_registration.h:322
std::span< const std::string_view > grant_types
The grant types the client will use (RFC 7591 Section 2).
Definition oauth_registration.h:170
auto client_id() const -> std::optional< std::string_view >
std::span< const std::string_view > response_types
The response types the client will use (RFC 7591 Section 2).
Definition oauth_registration.h:172
auto client_name() const -> std::optional< std::string_view >
The human-readable client name (RFC 7591 Section 2).
auto token_endpoint_auth_method() const -> std::string_view
auto client_uri() const -> std::optional< std::string_view >
The client information page (RFC 7591 Section 2).
std::string_view client_id
The issued client identifier (RFC 7591 Section 3.2.1), REQUIRED.
Definition oauth_registration.h:317
auto has_contact(const std::string_view value) const -> bool
Whether a contact is listed (RFC 7591 Section 2).
auto scope() const -> std::optional< std::string_view >
The space-separated scopes the client may request (RFC 7591 Section 2).
auto registration_access_token() const -> std::optional< std::string_view >
auto client_id_issued_at() const -> std::optional< std::chrono::seconds >
auto jwks_uri() const -> std::optional< std::string_view >
The JWK Set document location for the client's keys (RFC 7591 Section 2).
std::optional< std::chrono::seconds > client_secret_expires_at
Definition oauth_registration.h:325
std::string_view token_endpoint_auth_method
Definition oauth_registration.h:168
auto tos_uri() const -> std::optional< std::string_view >
The terms of service page (RFC 7591 Section 2).
std::string_view registration_access_token
Definition oauth_registration.h:329
auto supports_grant_type(const std::string_view value) const -> bool
std::string_view scope
The space-separated scopes the client may request (RFC 7591 Section 2).
Definition oauth_registration.h:180
auto registration_client_uri() const -> std::optional< std::string_view >
std::string_view client_name
The human-readable client name (RFC 7591 Section 2).
Definition oauth_registration.h:174
std::string_view software_statement
The software statement asserting the metadata (RFC 7591 Section 2.3).
Definition oauth_registration.h:199
std::string_view tos_uri
The terms of service page (RFC 7591 Section 2).
Definition oauth_registration.h:184
std::string_view client_secret
Definition oauth_registration.h:320
auto software_statement() const -> std::optional< std::string_view >
auto software_id() const -> std::optional< std::string_view >
auto software_version() const -> std::optional< std::string_view >
The client software version (RFC 7591 Section 2).
auto policy_uri() const -> std::optional< std::string_view >
The privacy policy page (RFC 7591 Section 2).
const JSON * jwks
Definition oauth_registration.h:193
Definition oauth_registration.h:53
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_registration_update_request(const OAuthClientRegistrationConfig &config, const std::string_view client_id, const std::string_view client_secret) -> std::optional< JSON >
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_registration_request(const OAuthClientRegistrationConfig &config) -> std::optional< JSON >
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_registration_error_response(const std::string_view error, const std::string_view error_description) -> JSON
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_registration_grant_response_consistent(const OAuthClientMetadata &metadata) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_apply_software_statement_claims(JSON &metadata, const JSON &claims) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_registration_response(const JSON &metadata, const OAuthClientRegistrationResult &result) -> std::optional< JSON >
Definition oauth_registration.h:162
Definition oauth_registration.h:315