#include <auth.hpp>
Inherited by pion::http::basic_auth, and pion::http::cookie_auth.
Public Member Functions | |
auth (user_manager_ptr userManager) | |
default constructor | |
virtual | ~auth () |
virtual destructor | |
virtual bool | handle_request (http::request_ptr &http_request_ptr, tcp::connection_ptr &tcp_conn)=0 |
virtual void | set_option (const std::string &name, const std::string &value) |
void | add_restrict (const std::string &resource) |
void | add_permit (const std::string &resource) |
virtual bool | add_user (std::string const &username, std::string const &password) |
virtual bool | update_user (std::string const &username, std::string const &password) |
virtual bool | remove_user (std::string const &username) |
virtual user_ptr | get_user (std::string const &username) |
Protected Types | |
typedef std::set< std::string > | resource_set_type |
data type for a set of resources to be authenticated | |
typedef std::map< std::string, std::pair < boost::posix_time::ptime, user_ptr > > | user_cache_type |
data type used to map authentication credentials to user objects | |
Protected Member Functions | |
bool | need_authentication (http::request_ptr const &http_request_ptr) const |
bool | find_resource (const resource_set_type &resource_set, const std::string &resource) const |
void | set_logger (logger log_ptr) |
sets the logger to be used | |
Protected Attributes | |
logger | m_logger |
primary logging interface used by this class | |
user_manager_ptr | m_user_manager |
container used to manager user objects | |
resource_set_type | m_restrict_list |
collection of resources that require authentication | |
resource_set_type | m_white_list |
collection of resources that do NOT require authentication | |
boost::mutex | m_resource_mutex |
mutex used to protect access to the resources |
auth: a base class for handling HTTP Authentication and session management
Definition at line 34 of file auth.hpp.
void pion::http::auth::add_permit | ( | 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 http_auth.cpp.
References m_logger, m_resource_mutex, m_white_list, and pion::http::server::strip_trailing_slash().
void pion::http::auth::add_restrict | ( | 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 http_auth.cpp.
References m_logger, m_resource_mutex, m_restrict_list, and pion::http::server::strip_trailing_slash().
virtual bool pion::http::auth::add_user | ( | std::string const & | username, | |
std::string const & | password | |||
) | [inline, virtual] |
bool pion::http::auth::find_resource | ( | const resource_set_type & | 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 http_auth.cpp.
Referenced by need_authentication().
virtual user_ptr pion::http::auth::get_user | ( | std::string const & | username | ) | [inline, virtual] |
virtual bool pion::http::auth::handle_request | ( | http::request_ptr & | http_request_ptr, | |
tcp::connection_ptr & | 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";
http_request_ptr | the new HTTP request to handle | |
tcp_conn | the TCP connection that has the new request |
Implemented in pion::http::basic_auth, and pion::http::cookie_auth.
bool pion::http::auth::need_authentication | ( | http::request_ptr const & | http_request_ptr | ) | const [protected] |
check if given HTTP request requires authentication
http_request_ptr | the HTTP request to check |
Definition at line 37 of file http_auth.cpp.
References find_resource(), m_resource_mutex, m_restrict_list, m_user_manager, m_white_list, and pion::http::server::strip_trailing_slash().
Referenced by pion::http::cookie_auth::handle_request(), and pion::http::basic_auth::handle_request().
virtual bool pion::http::auth::remove_user | ( | std::string const & | username | ) | [inline, virtual] |
virtual void pion::http::auth::set_option | ( | 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::http::basic_auth, and pion::http::cookie_auth.
virtual bool pion::http::auth::update_user | ( | std::string const & | username, | |
std::string const & | password | |||
) | [inline, virtual] |