aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net/http_protocol_handler.h
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2016-12-08 20:28:28 -0500
committerLee Clagett <code@leeclagett.com>2016-12-13 00:19:54 -0500
commitbdc3d7496f0ba6ca8a8a5992a33ab617fec8058b (patch)
treee9122ee2e7fcf0898d4d1538d51a54c08fb3add7 /contrib/epee/include/net/http_protocol_handler.h
parentMerge pull request #1436 (diff)
downloadmonero-bdc3d7496f0ba6ca8a8a5992a33ab617fec8058b.tar.xz
Adding HTTP Digest Auth (but not yet enabled)
Diffstat (limited to 'contrib/epee/include/net/http_protocol_handler.h')
-rw-r--r--contrib/epee/include/net/http_protocol_handler.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/epee/include/net/http_protocol_handler.h b/contrib/epee/include/net/http_protocol_handler.h
index 40e3392db..3813f9d7c 100644
--- a/contrib/epee/include/net/http_protocol_handler.h
+++ b/contrib/epee/include/net/http_protocol_handler.h
@@ -30,9 +30,11 @@
#ifndef _HTTP_SERVER_H_
#define _HTTP_SERVER_H_
+#include <boost/optional/optional.hpp>
#include <string>
#include "net_utils_base.h"
#include "to_nonconst_iterator.h"
+#include "http_auth.h"
#include "http_base.h"
namespace epee
@@ -50,6 +52,7 @@ namespace net_utils
{
std::string m_folder;
std::string m_required_user_agent;
+ boost::optional<http_auth::login> m_user;
critical_section m_lock;
};
@@ -169,11 +172,20 @@ namespace net_utils
http_custom_handler(i_service_endpoint* psnd_hndlr, config_type& config, t_connection_context& conn_context)
: simple_http_connection_handler<t_connection_context>(psnd_hndlr, config),
m_config(config),
- m_conn_context(conn_context)
+ m_conn_context(conn_context),
+ m_auth(m_config.m_user ? http_auth{*m_config.m_user} : http_auth{})
{}
inline bool handle_request(const http_request_info& query_info, http_response_info& response)
{
CHECK_AND_ASSERT_MES(m_config.m_phandler, false, "m_config.m_phandler is NULL!!!!");
+
+ const auto auth_response = m_auth.get_response(query_info);
+ if (auth_response)
+ {
+ response = std::move(*auth_response);
+ return true;
+ }
+
//fill with default values
response.m_mime_tipe = "text/plain";
response.m_response_code = 200;
@@ -202,6 +214,7 @@ namespace net_utils
//simple_http_connection_handler::config_type m_stub_config;
config_type& m_config;
t_connection_context& m_conn_context;
+ http_auth m_auth;
};
}
}