1#ifndef SOURCEMETA_CORE_OAUTH_ASSERTION_H_
2#define SOURCEMETA_CORE_OAUTH_ASSERTION_H_
4#ifndef SOURCEMETA_CORE_OAUTH_EXPORT
5#include <sourcemeta/core/oauth_export.h>
8#include <sourcemeta/core/crypto.h>
9#include <sourcemeta/core/jose_algorithm.h>
10#include <sourcemeta/core/jose_jwk_private.h>
11#include <sourcemeta/core/jose_jwks.h>
12#include <sourcemeta/core/oauth_dpop.h>
21namespace sourcemeta::core {
27 "urn:ietf:params:oauth:grant-type:jwt-bearer"};
32 "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"};
55 const std::string_view issuer,
const std::string_view subject,
56 const std::string_view audience,
const std::chrono::seconds lifetime,
57 const std::chrono::system_clock::time_point now,
const JWKPrivate &key,
58 const JWSAlgorithm algorithm) -> std::optional<std::string>;
81 const std::string_view client_id,
const std::string_view audience,
82 const std::chrono::seconds lifetime,
83 const std::chrono::system_clock::time_point now,
const JWKPrivate &key,
84 const JWSAlgorithm algorithm) -> std::optional<std::string>;
101SOURCEMETA_CORE_OAUTH_EXPORT
122SOURCEMETA_CORE_OAUTH_EXPORT
124 const std::string_view scope,
202 const std::string_view assertion,
203 const std::span<const std::string_view> expected_audiences,
204 const std::string_view request_client_id,
const JWKS &keys,
205 const std::chrono::system_clock::time_point now,
207 -> std::optional<OAuthAssertionError>;
235 const std::string_view assertion,
const std::string_view expected_issuer,
236 const std::span<const std::string_view> expected_audiences,
237 const JWKS &keys,
const std::chrono::system_clock::time_point now,
239 -> std::optional<OAuthAssertionError>;
JWSAlgorithm
Definition jose_algorithm.h:21
@ Issuer
The issuer claim is missing or does not match the expected value.
Definition jose_verify.h:28
@ Subject
The subject claim is missing or does not match the expected value.
Definition jose_verify.h:30
@ Audience
The audience claim is missing or does not contain the expected value.
Definition jose_verify.h:32
@ Signature
The named key was found but its signature did not verify.
Definition jose_verify.h:200
@ UnknownKey
No key in the set could be selected or verified the signature.
Definition jose_verify.h:198
std::chrono::seconds clock_skew
The tolerance applied to the expiration, not-before, and issue times.
Definition oauth_assertion.h:166
std::span< const JWSAlgorithm > allowed_algorithms
Definition oauth_assertion.h:164
OAuthDPoPReplayStore * replay_store
Definition oauth_assertion.h:170
constexpr std::string_view OAUTH_CLIENT_ASSERTION_TYPE_JWT_BEARER
Definition oauth_assertion.h:31
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_assertion(const std::string_view issuer, const std::string_view subject, const std::string_view audience, const std::chrono::seconds lifetime, const std::chrono::system_clock::time_point now, const JWKPrivate &key, const JWSAlgorithm algorithm) -> std::optional< std::string >
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_client_assertion(const std::string_view assertion, SecureString &sink) -> void
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_verify_assertion_grant(const std::string_view assertion, const std::string_view expected_issuer, const std::span< const std::string_view > expected_audiences, const JWKS &keys, const std::chrono::system_clock::time_point now, const OAuthAssertionVerifyOptions &options) -> std::optional< OAuthAssertionError >
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_client_assertion(const std::string_view client_id, const std::string_view audience, const std::chrono::seconds lifetime, const std::chrono::system_clock::time_point now, const JWKPrivate &key, const JWSAlgorithm algorithm) -> std::optional< std::string >
constexpr std::string_view OAUTH_GRANT_TYPE_JWT_BEARER
Definition oauth_assertion.h:26
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_verify_client_assertion(const std::string_view assertion, const std::span< const std::string_view > expected_audiences, const std::string_view request_client_id, const JWKS &keys, const std::chrono::system_clock::time_point now, const OAuthAssertionVerifyOptions &options) -> std::optional< OAuthAssertionError >
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_token_request_jwt_bearer(const std::string_view assertion, const std::string_view scope, SecureString &sink) -> void
OAuthAssertionError
Definition oauth_assertion.h:129
@ NotYetValid
The assertion is not yet valid (RFC 7523 Section 3 check 5).
Definition oauth_assertion.h:149
@ Malformed
The assertion was not a well-formed JSON Web Token.
Definition oauth_assertion.h:131
@ Expired
The assertion has expired (RFC 7523 Section 3 check 4).
Definition oauth_assertion.h:147
@ Replay
Definition oauth_assertion.h:154
@ UnsupportedAlgorithm
The algorithm was absent or outside the accepted set (RFC 7523 Section 5).
Definition oauth_assertion.h:133
@ IssuedInFuture
The issue time lies in the future (RFC 7523 Section 3 check 6).
Definition oauth_assertion.h:151