cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
server_auth_endpoints.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 [caomengxuan666]
2
3#pragma once
4
5#include <chrono>
6#include <functional>
7#include <optional>
8#include <string>
9#include <vector>
10
13#include "cxxmcp/auth/token.hpp"
14#include "cxxmcp/auth/types.hpp"
16
25
26namespace mcp::auth {
27
31 std::string response_type;
32 std::string client_id;
33 std::string redirect_uri;
34 std::string state;
35 std::optional<std::string> scope;
36 std::optional<std::string> code_challenge;
37 std::optional<std::string> code_challenge_method;
38 std::optional<std::string> resource;
39 std::optional<std::string> nonce;
40};
41
45 std::string authorization_code;
47 std::string state;
49 std::string redirect_uri;
50};
51
72
75 std::string grant_type;
76 std::optional<std::string> code;
77 std::optional<std::string> redirect_uri;
78 std::optional<std::string> client_id;
79 std::optional<std::string> client_secret;
80 std::optional<std::string> code_verifier;
81 std::optional<std::string> refresh_token;
82 std::optional<std::string> scope;
83 std::optional<std::string> resource;
84};
85
92 public:
93 virtual ~TokenEndpointHandler() = default;
94
100 const TokenRequestParams& params) = 0;
101};
102
119
122 std::string token;
123 std::optional<std::string> token_type_hint;
124 std::optional<std::string> client_id;
125 std::optional<std::string> client_secret;
126};
127
132 public:
133 virtual ~TokenRevocationEndpointHandler() = default;
134
140 const TokenRevocationParams& params) = 0;
141};
142
149 std::string access_token;
150 std::string token_type = "Bearer";
151 std::optional<std::string> refresh_token;
152 std::optional<std::chrono::seconds> expires_in;
153 std::optional<std::string> scope;
154 MetadataMap metadata;
155};
156
159 std::function<core::Result<AuthorizationDecision>(
161
163using TokenEndpointCallback = std::function<core::Result<TokenEndpointResponse>(
164 const TokenRequestParams&)>;
165
168 std::function<core::Result<ClientRegistrationResponse>(
170
173 std::function<core::Result<core::Unit>(const TokenRevocationParams&)>;
174
181 std::string issuer;
182 std::string authorize_path = "/authorize";
183 std::string token_path = "/token";
184 std::string registration_path = "/register";
185 std::string revocation_path = "/revoke";
186 ScopeList scopes_supported;
187 StringList grant_types_supported = {"authorization_code", "refresh_token"};
188 StringList response_types_supported = {"code"};
189 StringList code_challenge_methods_supported = {"S256"};
190 StringList token_endpoint_auth_methods_supported = {"none"};
191 std::optional<std::string> jwks_uri;
192 std::optional<std::string> service_documentation;
193 AuthorizationEndpointCallback authorization_handler;
194 TokenEndpointCallback token_handler;
195 ClientRegistrationEndpointCallback registration_handler;
196 TokenRevocationEndpointCallback revocation_handler;
197 MetadataMap metadata;
198};
199
200} // namespace mcp::auth
Shared lightweight value types for cxxmcp auth contracts.
Abstract handler for the authorization endpoint.
Definition server_auth_endpoints.hpp:59
virtual core::Result< AuthorizationDecision > authorize(const AuthorizationRequestParams &params)=0
Process an authorization request.
Abstract handler for the dynamic client registration endpoint.
Definition server_auth_endpoints.hpp:108
virtual core::Result< ClientRegistrationResponse > register_client(const ClientRegistrationRequest &request)=0
Process a client registration request.
Abstract handler for the token endpoint.
Definition server_auth_endpoints.hpp:91
virtual core::Result< TokenSet > issue_token(const TokenRequestParams &params)=0
Process a token request.
Abstract handler for the token revocation endpoint.
Definition server_auth_endpoints.hpp:131
virtual core::Result< core::Unit > revoke_token(const TokenRevocationParams &params)=0
Process a token revocation request.
RFC 9728 and RFC 8414 metadata value models.
Dynamic Client Registration and client metadata models.
Shared result and error primitives used by the public cxxmcp SDK.
tl::expected< T, Error > Result
Alias for the SDK result type.
Definition result.hpp:64
std::function< core::Result< TokenEndpointResponse >(const TokenRequestParams &)> TokenEndpointCallback
Function callback for the token endpoint.
Definition server_auth_endpoints.hpp:164
std::function< core::Result< AuthorizationDecision >(const AuthorizationRequestParams &)> AuthorizationEndpointCallback
Function callback for the authorization endpoint.
Definition server_auth_endpoints.hpp:160
std::function< core::Result< core::Unit >(const TokenRevocationParams &)> TokenRevocationEndpointCallback
Function callback for token revocation.
Definition server_auth_endpoints.hpp:173
std::function< core::Result< ClientRegistrationResponse >(const ClientRegistrationRequest &)> ClientRegistrationEndpointCallback
Function callback for dynamic client registration.
Definition server_auth_endpoints.hpp:169
Result of a successful authorization decision.
Definition server_auth_endpoints.hpp:43
std::string state
The state parameter to echo back (must match the request).
Definition server_auth_endpoints.hpp:47
std::string redirect_uri
The redirect URI to send the client to.
Definition server_auth_endpoints.hpp:49
std::string authorization_code
The authorization code to return to the client via redirect.
Definition server_auth_endpoints.hpp:45
Parameters parsed from an authorization request (RFC 6749 Section 4.1.1).
Definition server_auth_endpoints.hpp:30
OAuth authorization server endpoint wiring owned by the auth layer.
Definition server_auth_endpoints.hpp:180
RFC 7591 dynamic client registration request.
Definition registration.hpp:20
Token endpoint response serialized by an authorization server.
Definition server_auth_endpoints.hpp:148
Parameters parsed from a token request (RFC 6749 Section 4.1.3).
Definition server_auth_endpoints.hpp:74
Parameters parsed from a revocation request (RFC 7009).
Definition server_auth_endpoints.hpp:121
OAuth token models and storage contracts.