- Main Page
- Classes
- Files

- File List

# include/pion/http/basic_auth.hpp

    00001 // ---------------------------------------------------------------------
    00002 // pion:  a Boost C++ framework for building lightweight HTTP interfaces
    00003 // ---------------------------------------------------------------------
    00004 // Copyright (C) 2007-2014 Splunk Inc.  (https://github.com/splunk/pion)
    00005 //
    00006 // Distributed under the Boost Software License, Version 1.0.
    00007 // See http://www.boost.org/LICENSE_1_0.txt
    00008 //
    00009
    00010 #ifndef __PION_HTTP_BASIC_AUTH_HEADER__
    00011 #define __PION_HTTP_BASIC_AUTH_HEADER__
    00012
    00013 #include <map>
    00014 #include <string>
    00015 #include <pion/config.hpp>
    00016 #include <pion/http/auth.hpp>
    00017
    00018
    00019 namespace pion {    // begin namespace pion
    00020 namespace http {    // begin namespace http
    00021
    00026 class PION_API basic_auth :
    00027     public http::auth
    00028 {
    00029 public:
    00030
    00032     basic_auth(user_manager_ptr userManager, const std::string& realm="PION");
    00033
    00035     virtual ~basic_auth() {}
    00036
    00049     virtual bool handle_request(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
    00050
    00059     virtual void set_option(const std::string& name, const std::string& value);
    00060
    00061
    00062 protected:
    00063
    00070     void handle_unauthorized(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
    00071
    00077     static bool parse_authorization(std::string const &authorization, std::string &credentials);
    00078
    00082     static bool parse_credentials(std::string const &credentials, std::string &username, std::string &password);
    00083
    00084
    00085 private:
    00086
    00088     static const unsigned int   CACHE_EXPIRATION;
    00089
    00090
    00092     std::string                 m_realm;
    00093
    00095     boost::posix_time::ptime    m_cache_cleanup_time;
    00096
    00098     user_cache_type             m_user_cache;
    00099
    00101     mutable boost::mutex        m_cache_mutex;
    00102 };
    00103
    00104
    00105 }   // end namespace http
    00106 }   // end namespace pion
    00107
    00108 #endif