21 auto handler = [
this](
auto& ctx) {
23 std::string response_body;
25 const auto& path_params = ctx.rpc_ctx->get_request_path_params();
26 const auto url_token_it = path_params.find(
"token");
28 if (url_token_it == path_params.end())
30 ctx.rpc_ctx->set_response_status(HTTP_STATUS_NOT_FOUND);
31 ctx.rpc_ctx->set_response_body(
"no token in URL");
34 std::string token = url_token_it->second;
35 LOG_DEBUG_FMT(
"ACME: challenge request for token '{}'", token);
43 response_status = HTTP_STATUS_OK;
44 response_body = token +
"." + prit->second;
48 response_status = HTTP_STATUS_NOT_FOUND;
50 fmt::format(
"Challenge response for token '{}' not found", token);
55 response_status = HTTP_STATUS_OK;
56 response_body = token +
"." + tit->second;
59 ctx.rpc_ctx->set_response_status(response_status);
60 ctx.rpc_ctx->set_response_body(std::move(response_body));
63 make_endpoint(
"/{token}", HTTP_GET, handler, no_auth_required)
71 void add(
const std::string& token,
const std::string& response)
74 "ACME: challenge server received response for token '{}' ({})",
81 void remove(
const std::string& token)
103 void add(
const std::string& token,
const std::string& response)
Definition acme_challenge_frontend.h:15
virtual ~ACMERpcEndpoints()=default
void add(const std::string &token, const std::string &response)
Definition acme_challenge_frontend.h:71
ACMERpcEndpoints(NetworkState &network, ccf::AbstractNodeContext &context)
Definition acme_challenge_frontend.h:17
void remove(const std::string &token)
Definition acme_challenge_frontend.h:81
std::map< std::string, std::string > prepared_responses
Definition acme_challenge_frontend.h:87
Definition acme_challenge_frontend.h:91
virtual ~ACMERpcFrontend()=default
ACMERpcEndpoints endpoints
Definition acme_challenge_frontend.h:93
void add(const std::string &token, const std::string &response)
Definition acme_challenge_frontend.h:103
ACMERpcFrontend(NetworkState &network, ccf::AbstractNodeContext &context)
Definition acme_challenge_frontend.h:96
void remove(const std::string &token)
Definition acme_challenge_frontend.h:108
ccf::AbstractNodeContext & context
Definition base_endpoint_registry.h:123
Definition common_endpoint_registry.h:16
ccf::kv::Store & tables
Definition frontend.h:36
virtual Endpoint make_endpoint(const std::string &method, RESTVerb verb, const EndpointFunction &f, const AuthnPolicies &ap)
Definition endpoint_registry.cpp:204
void install(Endpoint &endpoint) override
Definition endpoint_registry.cpp:290
#define LOG_TRACE_FMT
Definition logger.h:356
#define LOG_DEBUG_FMT
Definition logger.h:357
Definition app_interface.h:14
constexpr auto get_actor_prefix(ActorsType at)
Definition actors.h:31
llhttp_status http_status
Definition http_status.h:9
ActorsType
Definition actors.h:11
Definition node_context.h:12
Definition network_state.h:12
Endpoint & set_forwarding_required(ForwardingRequired fr)
Definition endpoint.cpp:68
Endpoint & set_auto_schema(std::optional< http_status > status=std::nullopt)
Definition endpoint.h:345