Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
oauth_introspection.h
1#ifndef SOURCEMETA_CORE_OAUTH_INTROSPECTION_H_
2#define SOURCEMETA_CORE_OAUTH_INTROSPECTION_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 <chrono> // std::chrono::seconds
12#include <optional> // std::optional
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
38SOURCEMETA_CORE_OAUTH_EXPORT
39auto oauth_build_introspection_request(const std::string_view token,
40 const std::string_view token_type_hint,
41 SecureString &sink) -> void;
42
61class SOURCEMETA_CORE_OAUTH_EXPORT OAuthIntrospectionResponse {
62public:
66
69 [[nodiscard]] auto active() const noexcept -> bool;
70
72 [[nodiscard]] auto scope() const -> std::optional<std::string_view>;
74 [[nodiscard]] auto client_id() const -> std::optional<std::string_view>;
76 [[nodiscard]] auto username() const -> std::optional<std::string_view>;
79 [[nodiscard]] auto token_type() const -> std::optional<std::string_view>;
81 [[nodiscard]] auto subject() const -> std::optional<std::string_view>;
83 [[nodiscard]] auto issuer() const -> std::optional<std::string_view>;
85 [[nodiscard]] auto jti() const -> std::optional<std::string_view>;
87 [[nodiscard]] auto expiration() const -> std::optional<std::chrono::seconds>;
89 [[nodiscard]] auto issued_at() const -> std::optional<std::chrono::seconds>;
91 [[nodiscard]] auto not_before() const -> std::optional<std::chrono::seconds>;
92
95 [[nodiscard]] auto data() const -> const JSON &;
96
97private:
98 const JSON *data_;
99 bool active_;
100};
101
102#if defined(_MSC_VER)
103#pragma warning(default : 4251)
104#endif
105
118SOURCEMETA_CORE_OAUTH_EXPORT
120
121} // namespace sourcemeta::core
122
123#endif
Definition crypto_secure.h:162
Definition json_value.h:39
auto issued_at() const -> std::optional< std::chrono::seconds >
The issuance time (RFC 7662 Section 2.2).
auto jti() const -> std::optional< std::string_view >
The identifier of the token (RFC 7662 Section 2.2).
auto active() const noexcept -> bool
auto token_type() const -> std::optional< std::string_view >
auto client_id() const -> std::optional< std::string_view >
The client identifier the token was issued to (RFC 7662 Section 2.2).
auto issuer() const -> std::optional< std::string_view >
The issuer of the token (RFC 7662 Section 2.2).
auto subject() const -> std::optional< std::string_view >
The subject of the token (RFC 7662 Section 2.2).
auto expiration() const -> std::optional< std::chrono::seconds >
The expiration time (RFC 7662 Section 2.2), or no value when absent.
auto not_before() const -> std::optional< std::chrono::seconds >
The not-before time (RFC 7662 Section 2.2).
auto username() const -> std::optional< std::string_view >
The resource owner username (RFC 7662 Section 2.2).
auto scope() const -> std::optional< std::string_view >
The space-delimited scope (RFC 7662 Section 2.2), or no value when absent.
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_introspection_request(const std::string_view token, const std::string_view token_type_hint, SecureString &sink) -> void
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_introspection_inactive() -> JSON