Prometheus Client Library for Modern C++
Public Types | Public Member Functions | List of all members
prometheus::BasicAuthHandler Class Reference
Inheritance diagram for prometheus::BasicAuthHandler:
Inheritance graph
[legend]
Collaboration diagram for prometheus::BasicAuthHandler:
Collaboration graph
[legend]

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.