pion-net
4.0.9
|
#include <HTTPBasicAuth.hpp>
Inherits pion::net::HTTPAuth.
Public Member Functions | |
HTTPBasicAuth (PionUserManagerPtr userManager, const std::string &realm="PION:NET") | |
default constructor | |
virtual | ~HTTPBasicAuth () |
virtual destructor | |
virtual bool | handleRequest (HTTPRequestPtr &request, TCPConnectionPtr &tcp_conn) |
virtual void | setOption (const std::string &name, const std::string &value) |
![]() | |
HTTPAuth (PionUserManagerPtr userManager) | |
default constructor | |
virtual | ~HTTPAuth () |
virtual destructor | |
void | addRestrict (const std::string &resource) |
void | addPermit (const std::string &resource) |
virtual bool | addUser (std::string const &username, std::string const &password) |
virtual bool | updateUser (std::string const &username, std::string const &password) |
virtual bool | removeUser (std::string const &username) |
virtual PionUserPtr | getUser (std::string const &username) |
Protected Member Functions | |
void | handleUnauthorized (HTTPRequestPtr &http_request, TCPConnectionPtr &tcp_conn) |
![]() | |
bool | needAuthentication (HTTPRequestPtr const &http_request) const |
bool | findResource (const AuthResourceSet &resource_set, const std::string &resource) const |
void | setLogger (PionLogger log_ptr) |
sets the logger to be used | |
Static Protected Member Functions | |
static bool | parseAuthorization (std::string const &authorization, std::string &credentials) |
static bool | parseCredentials (std::string const &credentials, std::string &username, std::string &password) |
Additional Inherited Members | |
![]() | |
typedef std::set< std::string > | AuthResourceSet |
data type for a set of resources to be authenticated | |
![]() | |
PionLogger | m_logger |
primary logging interface used by this class | |
PionUserManagerPtr | m_user_manager |
container used to manager user objects | |
AuthResourceSet | m_restrict_list |
collection of resources that require authentication | |
AuthResourceSet | m_white_list |
collection of resources that do NOT require authentication | |
boost::mutex | m_resource_mutex |
mutex used to protect access to the resources | |
HTTPBasicAuth: a base class for handling HTTP Authentication and session management in accordance with RFC 2617 http://tools.ietf.org/html/rfc2617
Definition at line 27 of file HTTPBasicAuth.hpp.
|
virtual |
attempts to validate authentication of a new HTTP request. If request valid, pointer to user identity object (if any) will be preserved in the request and return "true". If request not authenticated, appropriate response is sent over tcp_conn and return "false";
request | the new HTTP request to handle |
tcp_conn | the TCP connection that has the new request |
Implements pion::net::HTTPAuth.
Definition at line 35 of file HTTPBasicAuth.cpp.
References handleUnauthorized(), pion::net::HTTPAuth::m_user_manager, pion::net::HTTPAuth::needAuthentication(), parseAuthorization(), and parseCredentials().
|
protected |
used to send responses when access to resource is not authorized
http_request | the new HTTP request to handle |
tcp_conn | the TCP connection that has the new request |
Definition at line 133 of file HTTPBasicAuth.cpp.
References pion::net::HTTPResponseWriter::create(), and pion::net::TCPConnection::finish().
Referenced by handleRequest().
|
staticprotected |
extracts base64 user credentials from authorization string
authorization | value of the HEADER_AUTHORIZATION |
Definition at line 104 of file HTTPBasicAuth.cpp.
Referenced by handleRequest().
|
staticprotected |
parse base64 credentials and extract username/password
Definition at line 114 of file HTTPBasicAuth.cpp.
References pion::algo::base64_decode().
Referenced by handleRequest().
|
virtual |
sets a configuration option Valid options:
name | the name of the option to change |
value | the value of the option |
Reimplemented from pion::net::HTTPAuth.
Definition at line 96 of file HTTPBasicAuth.cpp.