Prometheus Client Library for Modern C++
Loading...
Searching...
No Matches
prometheus::BasicAuthHandler Class Reference

#include <basic_auth.h>

Inheritance diagram for prometheus::BasicAuthHandler:
Collaboration diagram for prometheus::BasicAuthHandler:

Public Types

using AuthFunc = std::function<bool(const std::string&, const std::string&)>

Public Member Functions

 BasicAuthHandler (AuthFunc callback, std::string realm)
bool authorize (CivetServer *server, mg_connection *conn) override

Detailed Description

Handler for HTTP Basic authentication for Endpoints.

Member Function Documentation

◆ authorize()

bool prometheus::BasicAuthHandler::authorize ( CivetServer * server,
mg_connection * conn )
override

Implements civetweb authorization interface.

Attempts to extract a username and password from the Authorization header to pass to the owning AuthHandler, this->handler. If handler returns true, permits the request to proceed. If handler returns false, or the Auth header is absent, rejects the request with 401 Unauthorized.