Electroneum
Loading...
Searching...
No Matches
epee::net_utils::http::http_client_auth Class Reference

Implements RFC 2617 digest auth. Digests from RFC 7616 can be added. More...

#include <http_auth.h>

Classes

struct  session

Public Types

enum  status : std::uint8_t { kSuccess = 0 , kBadPassword , kParseFailure }

Public Member Functions

 http_client_auth ()
 http_client_auth (login credentials)
status handle_401 (const http_response_info &response)
boost::optional< std::pair< std::string, std::string > > get_auth_field (const boost::string_ref method, const boost::string_ref uri)

Detailed Description

Implements RFC 2617 digest auth. Digests from RFC 7616 can be added.

Definition at line 95 of file http_auth.h.

Member Enumeration Documentation

◆ status

Enumerator
kSuccess 
kBadPassword 
kParseFailure 

Definition at line 98 of file http_auth.h.

Constructor & Destructor Documentation

◆ http_client_auth() [1/2]

epee::net_utils::http::http_client_auth::http_client_auth ( )
inline

Definition at line 130 of file http_auth.h.

130: user() {}

◆ http_client_auth() [2/2]

epee::net_utils::http::http_client_auth::http_client_auth ( login credentials)

Definition at line 755 of file http_auth.cpp.

756 : user(session{std::move(credentials)}) {
757 }

Member Function Documentation

◆ get_auth_field()

boost::optional< std::pair< std::string, std::string > > epee::net_utils::http::http_client_auth::get_auth_field ( const boost::string_ref method,
const boost::string_ref uri )
inline

After calling handle_401, clients should call this function to generate an authentication field for every request.

Returns
A HTTP "Authorization" field if handle_401(...) previously returned kSuccess.

Definition at line 158 of file http_auth.h.

160 {
161 if (user)
162 return do_get_auth_field(method, uri);
163 return boost::none;
164 }

◆ handle_401()

status epee::net_utils::http::http_client_auth::handle_401 ( const http_response_info & response)
inline

Clients receiving a 401 response code from the server should call this function to process the server auth. Then, before every client request, get_auth_field() should be called to retrieve the newest authorization request.

Returns
kBadPassword if client will never be able to authenticate, kParseFailure if all server authentication responses were invalid, and kSuccess if get_auth_field is ready to generate authorization fields.

Definition at line 144 of file http_auth.h.

145 {
146 if (user)
147 return do_handle_401(response);
148 return kBadPassword;
149 }

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/net/http_auth.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/src/http_auth.cpp