pion::http::basic_auth Class Reference

#include <basic_auth.hpp>

Inherits pion::http::auth.

List of all members.

Public Member Functions

 basic_auth (user_manager_ptr userManager, const std::string &realm="PION")
 default constructor
virtual ~basic_auth ()
 virtual destructor
virtual bool handle_request (http::request_ptr &http_request_ptr, tcp::connection_ptr &tcp_conn)
virtual void set_option (const std::string &name, const std::string &value)

Protected Member Functions

void handle_unauthorized (http::request_ptr &http_request_ptr, tcp::connection_ptr &tcp_conn)

Static Protected Member Functions

static bool parse_authorization (std::string const &authorization, std::string &credentials)
static bool parse_credentials (std::string const &credentials, std::string &username, std::string &password)

Detailed Description

basic_auth: a base class for handling HTTP Authentication and session management in accordance with RFC 2617 http://tools.ietf.org/html/rfc2617

Definition at line 26 of file basic_auth.hpp.


Member Function Documentation

bool pion::http::basic_auth::handle_request ( http::request_ptr &  http_request_ptr,
tcp::connection_ptr &  tcp_conn 
) [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";

Parameters:
http_request_ptr the new HTTP request to handle
tcp_conn the TCP connection that has the new request
Returns:
true if request valid and user identity inserted into request

Implements pion::http::auth.

Definition at line 35 of file http_basic_auth.cpp.

References handle_unauthorized(), pion::http::auth::m_user_manager, pion::http::auth::need_authentication(), parse_authorization(), and parse_credentials().

void pion::http::basic_auth::handle_unauthorized ( http::request_ptr &  http_request_ptr,
tcp::connection_ptr &  tcp_conn 
) [protected]

used to send responses when access to resource is not authorized

Parameters:
http_request_ptr the new HTTP request to handle
tcp_conn the TCP connection that has the new request

Definition at line 133 of file http_basic_auth.cpp.

References pion::http::response_writer::create(), and pion::tcp::connection::finish().

Referenced by handle_request().

bool pion::http::basic_auth::parse_authorization ( std::string const &  authorization,
std::string &  credentials 
) [static, protected]

extracts base64 user credentials from authorization string

Parameters:
authorization value of the HEADER_AUTHORIZATION

Definition at line 104 of file http_basic_auth.cpp.

Referenced by handle_request().

bool pion::http::basic_auth::parse_credentials ( std::string const &  credentials,
std::string &  username,
std::string &  password 
) [static, protected]

parse base64 credentials and extract username/password

Definition at line 114 of file http_basic_auth.cpp.

References pion::algorithm::base64_decode().

Referenced by handle_request().

void pion::http::basic_auth::set_option ( const std::string &  name,
const std::string &  value 
) [virtual]

sets a configuration option Valid options:

  • "domain" - name of authentication domain
Parameters:
name the name of the option to change
value the value of the option

Reimplemented from pion::http::auth.

Definition at line 96 of file http_basic_auth.cpp.


The documentation for this class was generated from the following files:

Generated on 16 Sep 2013 for pion by  doxygen 1.6.1