20 #include <ripple/rpc/Role.h>
21 #include <boost/beast/core/string.hpp>
22 #include <boost/beast/http/field.hpp>
23 #include <boost/beast/http/rfc7230.hpp>
24 #include <boost/utility/string_view.hpp>
33 bool const passwordRequired =
36 return !passwordRequired ||
37 ((params[
"admin_password"].
isString() &&
39 (params[
"admin_user"].isString() &&
52 return ip.is_unspecified() || ip == remoteIp;
72 boost::string_view
const& user)
101 Role const& required,
115 boost::string_view
const& user,
128 auto it = request.find(boost::beast::http::field::forwarded);
129 if (it != request.end())
131 auto ascii_tolower = [](
char c) ->
char {
132 return ((
static_cast<unsigned>(c) - 65U) < 26) ? c +
'a' -
'A' : c;
141 [&ascii_tolower](
char c1,
char c2) {
142 return ascii_tolower(c1) == ascii_tolower(c2);
145 if (found == it->value().end())
148 found += forStr.size();
151 boost::string_view(found, it->value().end() - found).find(
';')};
152 if (pos == boost::string_view::npos)
153 return it->value().size() - forStr.size();
157 return *boost::beast::http::token_list(boost::string_view(found, pos))
161 it = request.find(
"X-Forwarded-For");
162 if (it != request.end())
164 return *boost::beast::http::token_list(it->value()).begin();
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
bool isAdmin(Port const &port, Json::Value const ¶ms, beast::IP::Address const &remoteIp)
std::vector< beast::IP::Address > admin_ip
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
bool passwordUnrequiredOrSentCorrect(Port const &port, Json::Value const ¶ms)
Resource::Consumer requestInboundEndpoint(Resource::Manager &manager, beast::IP::Endpoint const &remoteAddress, Role const &role, boost::string_view const &user, boost::string_view const &forwardedFor)
Address const & address() const
Returns the address portion of this endpoint.
boost::asio::ip::address Address
boost::string_view forwardedFor(http_request_type const &request)
std::vector< beast::IP::Address > secure_gateway_ip
Role requestRole(Role const &required, Port const &port, Json::Value const ¶ms, beast::IP::Endpoint const &remoteIp, boost::string_view const &user)
Return the allowed privilege role.
Configuration information for a Server listening port.
std::string admin_password
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Tracks load and resource consumption.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual Consumer newUnlimitedEndpoint(beast::IP::Endpoint const &address)=0
Create a new unlimited endpoint keyed by forwarded IP.
bool ipAllowed(beast::IP::Address const &remoteIp, std::vector< beast::IP::Address > const &adminIp)
True if remoteIp is in any of adminIp.
A version-independent IP address and port combination.
Role
Indicates the level of administrative permission to grant.
std::string asString() const
Returns the unquoted string value.