PionNetworkLibrary
|
#include <auth.hpp>
Public Member Functions | |
auth (user_manager_ptr userManager) | |
default constructor More... | |
virtual | ~auth () |
virtual destructor More... | |
virtual bool | handle_request (const http::request_ptr &http_request_ptr, const tcp::connection_ptr &tcp_conn)=0 |
virtual void | set_option (const std::string &name, const std::string &) |
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 More... | |
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 More... | |
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 More... | |
Protected Attributes | |
logger | m_logger |
primary logging interface used by this class More... | |
user_manager_ptr | m_user_manager |
container used to manager user objects More... | |
resource_set_type | m_restrict_list |
collection of resources that require authentication More... | |
resource_set_type | m_white_list |
collection of resources that do NOT require authentication More... | |
boost::mutex | m_resource_mutex |
mutex used to protect access to the resources More... | |
auth: a base class for handling HTTP Authentication and session management
|
protected |
data type for a set of resources to be authenticated
|
protected |
data type used to map authentication credentials to user objects
|
inline |
default constructor
|
inlinevirtual |
virtual destructor
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 |
References m_logger, m_resource_mutex, m_white_list, PION_LOG_INFO, 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 |
References m_logger, m_resource_mutex, m_restrict_list, PION_LOG_INFO, and pion::http::server::strip_trailing_slash().
|
inlinevirtual |
used to add a new user
@ return false if user with such name already exists
|
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 |
Referenced by need_authentication().
|
inlinevirtual |
Used to locate user object by username
|
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::cookie_auth, and pion::http::basic_auth.
|
protected |
check if given HTTP request requires authentication
http_request_ptr | the HTTP request to check |
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::basic_auth::handle_request(), and pion::http::cookie_auth::handle_request().
|
inlinevirtual |
used to remove given user
|
inlineprotected |
sets the logger to be used
Referenced by pion::http::basic_auth::basic_auth(), and pion::http::cookie_auth::cookie_auth().
|
inlinevirtual |
sets a configuration option
name | the name of the option to change |
value | the value of the option |
Reimplemented in pion::http::cookie_auth, and pion::http::basic_auth.
|
inlinevirtual |
update password for given user
|
mutableprotected |
primary logging interface used by this class
Referenced by add_permit(), and add_restrict().
|
mutableprotected |
mutex used to protect access to the resources
Referenced by add_permit(), add_restrict(), and need_authentication().
|
protected |
collection of resources that require authentication
Referenced by add_restrict(), and need_authentication().
|
protected |
container used to manager user objects
Referenced by pion::http::basic_auth::handle_request(), need_authentication(), and pion::http::cookie_auth::process_login().
|
protected |
collection of resources that do NOT require authentication
Referenced by add_permit(), and need_authentication().