13#include "nlohmann/json.hpp"
30 if (request.jwks_uri.empty()) {
31 return core::unexpected(
32 core::Error{
static_cast<int>(OAuthErrorCode::kInvalidRequest),
33 "JWKS URI is required",
35 std::string(AuthErrorCategory)});
39 fetch_request.url = request.jwks_uri;
40 fetch_request.headers = request.headers;
42 auto response = get_(fetch_request);
43 if (!response.has_value()) {
44 return core::unexpected(response.error());
46 if (response->status_code < 200 || response->status_code >= 300) {
48 static_cast<int>(OAuthErrorCode::kMetadataDiscoveryFailed),
49 "JWKS fetch failed with HTTP " +
50 std::to_string(response->status_code),
52 std::string(AuthErrorCategory)});
55 nlohmann::json parsed;
57 parsed = nlohmann::json::parse(response->body);
58 }
catch (
const nlohmann::json::parse_error& ex) {
60 static_cast<int>(OAuthErrorCode::kMetadataDiscoveryFailed),
61 "JWKS response is not valid JSON", ex.what(),
62 std::string(AuthErrorCategory)});
Shared lightweight value types for cxxmcp auth contracts.
Concrete implementation of JwksEndpoint that fetches JWKS over HTTP.
Definition http_jwks_endpoint.hpp:24
Application-provided JWKS retrieval boundary.
Definition jwks.hpp:60
JWKS value models, parsing, fetch, and cache contracts.
core::Result< JsonWebKeySet > parse_json_web_key_set(const nlohmann::json &value)
Parse a public JWKS document from JSON.
Definition jwks.hpp:211
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
Request for retrieving a JWKS document.
Definition jwks.hpp:54
Structured error returned by fallible SDK operations.
Definition result.hpp:35