10 #ifndef __PION_HTTPAUTH_HEADER__
11 #define __PION_HTTPAUTH_HEADER__
14 #include <boost/noncopyable.hpp>
15 #include <boost/shared_ptr.hpp>
16 #include <pion/PionConfig.hpp>
17 #include <pion/PionLogger.hpp>
18 #include <pion/PionException.hpp>
19 #include <pion/net/PionUser.hpp>
20 #include <pion/net/TCPConnection.hpp>
21 #include <pion/net/HTTPRequest.hpp>
31 private boost::noncopyable
39 :
PionException(
"Option not recognized by authentication service: ", name) {}
45 : m_logger(PION_GET_LOGGER(
"pion.net.HTTPAuth")),
46 m_user_manager(userManager)
64 virtual bool handleRequest(HTTPRequestPtr& request, TCPConnectionPtr& tcp_conn) = 0;
72 virtual void setOption(
const std::string& name,
const std::string& value) {
81 void addRestrict(
const std::string& resource);
88 void addPermit(
const std::string& resource);
95 virtual bool addUser(std::string
const &username, std::string
const &password) {
96 return m_user_manager->addUser(username, password);
104 virtual bool updateUser(std::string
const &username, std::string
const &password) {
105 return m_user_manager->updateUser(username, password);
114 return m_user_manager->removeUser(username);
120 virtual PionUserPtr
getUser(std::string
const &username) {
121 return m_user_manager->getUser(username);
136 bool needAuthentication(HTTPRequestPtr
const& http_request)
const;
146 bool findResource(
const AuthResourceSet& resource_set,
147 const std::string& resource)
const;
170 typedef boost::shared_ptr<HTTPAuth> HTTPAuthPtr;
PionUserManagerPtr m_user_manager
container used to manager user objects
virtual bool updateUser(std::string const &username, std::string const &password)
AuthResourceSet m_white_list
collection of resources that do NOT require authentication
PionLogger m_logger
primary logging interface used by this class
virtual ~HTTPAuth()
virtual destructor
void setLogger(PionLogger log_ptr)
sets the logger to be used
virtual bool addUser(std::string const &username, std::string const &password)
HTTPAuth(PionUserManagerPtr userManager)
default constructor
boost::mutex m_resource_mutex
mutex used to protect access to the resources
AuthResourceSet m_restrict_list
collection of resources that require authentication
the following enables use of the lock-free cache
exception thrown if the service does not recognize a configuration option
std::set< std::string > AuthResourceSet
data type for a set of resources to be authenticated
virtual void setOption(const std::string &name, const std::string &value)
virtual PionUserPtr getUser(std::string const &username)
virtual bool removeUser(std::string const &username)