Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
oauth_authorization.h
1#ifndef SOURCEMETA_CORE_OAUTH_AUTHORIZATION_H_
2#define SOURCEMETA_CORE_OAUTH_AUTHORIZATION_H_
3
4#ifndef SOURCEMETA_CORE_OAUTH_EXPORT
5#include <sourcemeta/core/oauth_export.h>
6#endif
7
8#include <sourcemeta/core/oauth_profile.h>
9
10#include <cstdint> // std::uint8_t
11#include <functional> // std::function
12#include <optional> // std::optional
13#include <span> // std::span
14#include <string> // std::string
15#include <string_view> // std::string_view
16
17namespace sourcemeta::core {
18
31 std::string_view name;
33 std::string_view value;
34};
35
60 std::string_view client_id;
63 std::string_view redirect_uri;
65 std::string_view scope;
68 std::string_view state;
70 std::string_view code_challenge;
73 std::string_view code_challenge_method;
75 std::string_view request_uri;
77 std::string_view dpop_jkt;
84 std::string_view response_type;
87 std::span<const OAuthParameter> resources;
90 std::span<const OAuthParameter> extra;
91};
92
116SOURCEMETA_CORE_OAUTH_EXPORT
117auto oauth_build_authorization_url(const std::string_view endpoint,
118 const OAuthAuthorizationRequest &request,
119 std::string &sink) -> void;
120
146SOURCEMETA_CORE_OAUTH_EXPORT
148 const std::string_view query, std::string &storage,
150 const std::function<void(std::string_view, std::string_view)> &on_other)
151 -> bool;
152
170SOURCEMETA_CORE_OAUTH_EXPORT
171auto oauth_redirect_uri_matches(const std::string_view registered,
172 const std::string_view presented,
173 const OAuthProfile profile) -> bool;
174
187SOURCEMETA_CORE_OAUTH_EXPORT
188auto oauth_is_private_use_scheme(const std::string_view scheme) noexcept
189 -> bool;
190
199 std::string_view code;
201 std::string_view state;
203 std::string_view iss;
205 std::string_view error;
208 std::string_view error_description;
211 std::string_view error_uri;
212};
213
234SOURCEMETA_CORE_OAUTH_EXPORT
235auto oauth_parse_authorization_response(const std::string_view query,
236 std::string &storage,
238 -> bool;
239
266SOURCEMETA_CORE_OAUTH_EXPORT
268 const std::string_view redirect_uri,
269 const OAuthAuthorizationResponse &response, std::string &sink) -> bool;
270
294SOURCEMETA_CORE_OAUTH_EXPORT
296 const std::string_view redirect_uri,
297 const OAuthAuthorizationResponse &response, std::string &sink) -> bool;
298
303enum class OAuthResponseMode : std::uint8_t {
316};
317
336SOURCEMETA_CORE_OAUTH_EXPORT
337auto oauth_default_response_mode(const std::string_view response_type)
338 -> std::optional<OAuthResponseMode>;
339
354SOURCEMETA_CORE_OAUTH_EXPORT
355auto oauth_is_response_mode_allowed(const std::string_view response_type,
356 const OAuthResponseMode mode) -> bool;
357
380SOURCEMETA_CORE_OAUTH_EXPORT
382 const std::string_view redirect_uri,
383 const OAuthAuthorizationResponse &response, const OAuthResponseMode mode,
384 std::string &sink) -> bool;
385
406SOURCEMETA_CORE_OAUTH_EXPORT
408 const std::string_view redirect_uri,
409 const OAuthAuthorizationResponse &response, const OAuthResponseMode mode,
410 std::string &sink) -> bool;
411
435SOURCEMETA_CORE_OAUTH_EXPORT
437 const std::string_view redirect_uri,
438 const OAuthAuthorizationResponse &response, std::string &sink,
439 const std::string_view title = "Submit This Form") -> bool;
440
463SOURCEMETA_CORE_OAUTH_EXPORT
465 const std::string_view redirect_uri,
466 const OAuthAuthorizationResponse &response, std::string &sink,
467 const std::string_view title = "Submit This Form") -> bool;
468
469} // namespace sourcemeta::core
470
471#endif
std::string_view error_description
Definition oauth_authorization.h:208
std::string_view code_challenge
The PKCE code challenge (RFC 7636 Section 4.3).
Definition oauth_authorization.h:70
std::string_view state
The state value echoed from the request (RFC 6749 Section 4.1.2).
Definition oauth_authorization.h:201
std::string_view state
Definition oauth_authorization.h:68
std::span< const OAuthParameter > extra
Definition oauth_authorization.h:90
std::span< const OAuthParameter > resources
Definition oauth_authorization.h:87
std::string_view iss
The issuer identifier of the authorization server (RFC 9207 Section 2).
Definition oauth_authorization.h:203
std::string_view error_uri
Definition oauth_authorization.h:211
std::string_view response_type
Definition oauth_authorization.h:84
std::string_view redirect_uri
Definition oauth_authorization.h:63
std::string_view code_challenge_method
Definition oauth_authorization.h:73
std::string_view value
The parameter value, still in its raw unescaped form.
Definition oauth_authorization.h:33
std::string_view error
The error code of a failure response (RFC 6749 Section 4.1.2.1).
Definition oauth_authorization.h:205
std::string_view dpop_jkt
The JWK thumbprint of the DPoP proof public key (RFC 9449 Section 10).
Definition oauth_authorization.h:77
std::string_view request_uri
The reference to a pushed authorization request (RFC 9126 Section 4).
Definition oauth_authorization.h:75
std::string_view code
The authorization code (RFC 6749 Section 4.1.2).
Definition oauth_authorization.h:199
std::string_view name
The parameter name.
Definition oauth_authorization.h:31
std::string_view client_id
The client identifier (RFC 6749 Section 2.2).
Definition oauth_authorization.h:60
std::string_view scope
The space-delimited requested scope (RFC 6749 Section 3.3).
Definition oauth_authorization.h:65
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_default_response_mode(const std::string_view response_type) -> std::optional< OAuthResponseMode >
OAuthResponseMode
Definition oauth_authorization.h:303
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_authorization_error_redirect(const std::string_view redirect_uri, const OAuthAuthorizationResponse &response, std::string &sink) -> bool
OAuthProfile
Definition oauth_profile.h:23
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_parse_authorization_response(const std::string_view query, std::string &storage, OAuthAuthorizationResponse &result) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_authorization_url(const std::string_view endpoint, const OAuthAuthorizationRequest &request, std::string &sink) -> void
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_authorization_redirect(const std::string_view redirect_uri, const OAuthAuthorizationResponse &response, std::string &sink) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_parse_authorization_request(const std::string_view query, std::string &storage, OAuthAuthorizationRequest &result, const std::function< void(std::string_view, std::string_view)> &on_other) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_is_response_mode_allowed(const std::string_view response_type, const OAuthResponseMode mode) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_is_private_use_scheme(const std::string_view scheme) noexcept -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_redirect_uri_matches(const std::string_view registered, const std::string_view presented, const OAuthProfile profile) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_authorization_form_post(const std::string_view redirect_uri, const OAuthAuthorizationResponse &response, std::string &sink, const std::string_view title="Submit This Form") -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_authorization_error_form_post(const std::string_view redirect_uri, const OAuthAuthorizationResponse &response, std::string &sink, const std::string_view title="Submit This Form") -> bool
@ Fragment
Definition oauth_authorization.h:311
@ Query
Definition oauth_authorization.h:307
@ FormPost
Definition oauth_authorization.h:315
Definition oauth_authorization.h:58
Definition oauth_authorization.h:197
Definition oauth_authorization.h:29