Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
oauth_token_exchange.h
1#ifndef SOURCEMETA_CORE_OAUTH_TOKEN_EXCHANGE_H_
2#define SOURCEMETA_CORE_OAUTH_TOKEN_EXCHANGE_H_
3
4#ifndef SOURCEMETA_CORE_OAUTH_EXPORT
5#include <sourcemeta/core/oauth_export.h>
6#endif
7
8#include <sourcemeta/core/crypto.h>
9#include <sourcemeta/core/json.h>
10
11#include <optional> // std::optional
12#include <span> // std::span
13#include <string_view> // std::string_view
14
15namespace sourcemeta::core {
16
19inline constexpr std::string_view OAUTH_TOKEN_TYPE_ACCESS_TOKEN{
20 "urn:ietf:params:oauth:token-type:access_token"};
21
23inline constexpr std::string_view OAUTH_TOKEN_TYPE_REFRESH_TOKEN{
24 "urn:ietf:params:oauth:token-type:refresh_token"};
25
27inline constexpr std::string_view OAUTH_TOKEN_TYPE_ID_TOKEN{
28 "urn:ietf:params:oauth:token-type:id_token"};
29
31inline constexpr std::string_view OAUTH_TOKEN_TYPE_SAML1{
32 "urn:ietf:params:oauth:token-type:saml1"};
33
35inline constexpr std::string_view OAUTH_TOKEN_TYPE_SAML2{
36 "urn:ietf:params:oauth:token-type:saml2"};
37
39inline constexpr std::string_view OAUTH_TOKEN_TYPE_JWT{
40 "urn:ietf:params:oauth:token-type:jwt"};
41
50 std::string_view subject_token;
52 std::string_view subject_token_type;
55 std::string_view actor_token;
57 std::string_view actor_token_type;
59 std::string_view requested_token_type;
61 std::string_view scope;
64 std::span<const std::string_view> audiences;
67 std::span<const std::string_view> resources;
68};
69
87SOURCEMETA_CORE_OAUTH_EXPORT
89 -> bool;
90
112SOURCEMETA_CORE_OAUTH_EXPORT
114 const OAuthTokenExchangeRequest &request, SecureString &sink) -> bool;
115
134SOURCEMETA_CORE_OAUTH_EXPORT
135auto oauth_issued_token_type(const JSON &response)
136 -> std::optional<std::string_view>;
137
138} // namespace sourcemeta::core
139
140#endif
Definition crypto_secure.h:162
Definition json_value.h:39
std::string_view actor_token_type
The type of the actor token, emitted only together with the actor token.
Definition oauth_token_exchange.h:57
std::string_view requested_token_type
The requested type for the issued token (RFC 8693 Section 2.1).
Definition oauth_token_exchange.h:59
std::span< const std::string_view > audiences
Definition oauth_token_exchange.h:64
std::string_view subject_token_type
The type of the subject token, REQUIRED (RFC 8693 Section 2.1).
Definition oauth_token_exchange.h:52
std::span< const std::string_view > resources
Definition oauth_token_exchange.h:67
std::string_view scope
The space-delimited requested scope (RFC 6749 Section 3.3).
Definition oauth_token_exchange.h:61
std::string_view actor_token
Definition oauth_token_exchange.h:55
std::string_view subject_token
Definition oauth_token_exchange.h:50
constexpr std::string_view OAUTH_TOKEN_TYPE_ACCESS_TOKEN
Definition oauth_token_exchange.h:19
constexpr std::string_view OAUTH_TOKEN_TYPE_JWT
Definition oauth_token_exchange.h:39
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_token_exchange_valid(const OAuthTokenExchangeRequest &request) -> bool
constexpr std::string_view OAUTH_TOKEN_TYPE_SAML1
Definition oauth_token_exchange.h:31
constexpr std::string_view OAUTH_TOKEN_TYPE_REFRESH_TOKEN
Definition oauth_token_exchange.h:23
constexpr std::string_view OAUTH_TOKEN_TYPE_ID_TOKEN
Definition oauth_token_exchange.h:27
constexpr std::string_view OAUTH_TOKEN_TYPE_SAML2
Definition oauth_token_exchange.h:35
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_token_request_exchange(const OAuthTokenExchangeRequest &request, SecureString &sink) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_issued_token_type(const JSON &response) -> std::optional< std::string_view >
Definition oauth_token_exchange.h:47