rippled
Role.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_SERVER_ROLE_H_INCLUDED
21 #define RIPPLE_SERVER_ROLE_H_INCLUDED
22 
23 #include <ripple/beast/net/IPEndpoint.h>
24 #include <ripple/json/json_value.h>
25 #include <ripple/resource/ResourceManager.h>
26 #include <ripple/server/Handoff.h>
27 #include <ripple/server/Port.h>
28 #include <boost/asio/ip/network_v4.hpp>
29 #include <boost/asio/ip/network_v6.hpp>
30 #include <boost/utility/string_view.hpp>
31 #include <string>
32 #include <variant>
33 #include <vector>
34 
35 namespace ripple {
36 
43 enum class Role { GUEST, USER, IDENTIFIED, ADMIN, PROXY, FORBID };
44 
53 Role
55  Role const& required,
56  Port const& port,
57  Json::Value const& params,
58  beast::IP::Endpoint const& remoteIp,
59  boost::string_view const& user);
60 
61 Resource::Consumer
63  Resource::Manager& manager,
64  beast::IP::Endpoint const& remoteAddress,
65  Role const& role,
66  boost::string_view const& user,
67  boost::string_view const& forwardedFor);
68 
72 bool
73 isUnlimited(Role const& role);
74 
82 bool
83 ipAllowed(
84  beast::IP::Address const& remoteIp,
87 
88 boost::string_view
89 forwardedFor(http_request_type const& request);
90 
91 } // namespace ripple
92 
93 #endif
vector
ripple::requestInboundEndpoint
Resource::Consumer requestInboundEndpoint(Resource::Manager &manager, beast::IP::Endpoint const &remoteAddress, Role const &role, boost::string_view const &user, boost::string_view const &forwardedFor)
Definition: Role.cpp:141
ripple::Role::IDENTIFIED
@ IDENTIFIED
beast::IP::Address
boost::asio::ip::address Address
Definition: IPAddress.h:41
ripple::Role::ADMIN
@ ADMIN
ripple::Role::USER
@ USER
ripple::forwardedFor
boost::string_view forwardedFor(http_request_type const &request)
Definition: Role.cpp:261
ripple::Role::PROXY
@ PROXY
ripple::Role::FORBID
@ FORBID
ripple::requestRole
Role requestRole(Role const &required, Port const &port, Json::Value const &params, beast::IP::Endpoint const &remoteIp, boost::string_view const &user)
Return the allowed privilege role.
Definition: Role.cpp:94
ripple::isUnlimited
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Definition: Role.cpp:124
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Role::GUEST
@ GUEST
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
ripple::ipAllowed
bool ipAllowed(beast::IP::Address const &remoteIp, std::vector< boost::asio::ip::network_v4 > const &nets4, std::vector< boost::asio::ip::network_v6 > const &nets6)
True if remoteIp is in any of adminIp.
Definition: Role.cpp:45
ripple::Role
Role
Indicates the level of administrative permission to grant.
Definition: Role.h:43
Json::Value
Represents a JSON value.
Definition: json_value.h:145
variant
string