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>
37 return !passwordRequired ||
38 ((params[
"admin_password"].
isString() &&
40 (params[
"admin_user"].isString() &&
50 ip == remoteIp; }) != adminIp.
end ();
64 boost::string_view
const& user)
102 boost::string_view
const& user, boost::string_view
const&
forwardedFor)
114 auto it = request.find(boost::beast::http::field::forwarded);
115 if (it != request.end())
117 auto ascii_tolower = [](
char c) ->
char
119 return ((
static_cast<unsigned>(c) - 65U) < 26) ?
124 auto found =
std::search(it->value().begin(), it->value().end(),
125 forStr.begin(), forStr.end(),
126 [&ascii_tolower](
char c1,
char c2)
128 return ascii_tolower(c1) == ascii_tolower(c2);
132 if (found == it->value().end())
135 found += forStr.size();
139 found, it->value().end() - found).find(
';')};
140 if (pos == boost::string_view::npos)
141 return it->value().size() - forStr.size();
145 return *boost::beast::http::token_list(
146 boost::string_view(found, pos)).begin();
149 it = request.find(
"X-Forwarded-For");
150 if (it != request.end())
152 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.