#include <HTTPAuth.hpp>
Inherited by pion::net::HTTPBasicAuth, and pion::net::HTTPCookieAuth.
Definition at line 30 of file HTTPAuth.hpp.
Public Member Functions | |
HTTPAuth (PionUserManagerPtr userManager) | |
default constructor | |
virtual | ~HTTPAuth () |
virtual destructor | |
virtual bool | handleRequest (HTTPRequestPtr &request, TCPConnectionPtr &tcp_conn)=0 |
virtual void | setOption (const std::string &name, const std::string &value) |
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 Types | |
typedef std::set< std::string > | AuthResourceSet |
data type for a set of resources to be authenticated | |
Protected Member Functions | |
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 | |
Protected Attributes | |
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 | |
Classes | |
class | UnknownOptionException |
exception thrown if the service does not recognize a configuration option More... |
void pion::net::HTTPAuth::addPermit | ( | const std::string & | resource | ) |
adds a resource that does NOT require authentication
resource | the resource name or uri-stem that does not require authentication |
Definition at line 29 of file HTTPAuth.cpp.
References m_logger, m_resource_mutex, m_white_list, and pion::net::HTTPServer::stripTrailingSlash().
void pion::net::HTTPAuth::addRestrict | ( | const std::string & | resource | ) |
adds a resource that requires authentication
resource | the resource name or uri-stem that requires authentication |
Definition at line 21 of file HTTPAuth.cpp.
References m_logger, m_resource_mutex, m_restrict_list, and pion::net::HTTPServer::stripTrailingSlash().
virtual bool pion::net::HTTPAuth::addUser | ( | std::string const & | username, | |
std::string const & | password | |||
) | [inline, virtual] |
used to add a new user
@ return false if user with such name already exists
Definition at line 95 of file HTTPAuth.hpp.
bool pion::net::HTTPAuth::findResource | ( | const AuthResourceSet & | resource_set, | |
const std::string & | resource | |||
) | const [protected] |
tries to find a resource in a given collection
resource_set | the collection of resource to look in | |
resource | the resource to look for |
Definition at line 65 of file HTTPAuth.cpp.
Referenced by needAuthentication().
virtual PionUserPtr pion::net::HTTPAuth::getUser | ( | std::string const & | username | ) | [inline, virtual] |
Used to locate user object by username
Definition at line 120 of file HTTPAuth.hpp.
virtual bool pion::net::HTTPAuth::handleRequest | ( | HTTPRequestPtr & | request, | |
TCPConnectionPtr & | tcp_conn | |||
) | [pure 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 |
Implemented in pion::net::HTTPBasicAuth, and pion::net::HTTPCookieAuth.
bool pion::net::HTTPAuth::needAuthentication | ( | HTTPRequestPtr const & | http_request | ) | const [protected] |
check if given HTTP request requires authentication
http_request | the HTTP request to check |
Definition at line 37 of file HTTPAuth.cpp.
References findResource(), m_resource_mutex, m_restrict_list, m_user_manager, m_white_list, and pion::net::HTTPServer::stripTrailingSlash().
Referenced by pion::net::HTTPCookieAuth::handleRequest(), and pion::net::HTTPBasicAuth::handleRequest().
virtual bool pion::net::HTTPAuth::removeUser | ( | std::string const & | username | ) | [inline, virtual] |
used to remove given user
Definition at line 113 of file HTTPAuth.hpp.
virtual void pion::net::HTTPAuth::setOption | ( | const std::string & | name, | |
const std::string & | value | |||
) | [inline, virtual] |
sets a configuration option
name | the name of the option to change | |
value | the value of the option |
Reimplemented in pion::net::HTTPBasicAuth, and pion::net::HTTPCookieAuth.
Definition at line 72 of file HTTPAuth.hpp.
virtual bool pion::net::HTTPAuth::updateUser | ( | std::string const & | username, | |
std::string const & | password | |||
) | [inline, virtual] |
update password for given user
Definition at line 104 of file HTTPAuth.hpp.