Apache Mesos
firewall.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License
12 
13 #ifndef __PROCESS_FIREWALL_HPP__
14 #define __PROCESS_FIREWALL_HPP__
15 
16 #include <string>
17 
18 #include <process/http.hpp>
19 #include <process/owned.hpp>
20 #include <process/socket.hpp>
21 
22 #include <stout/error.hpp>
23 #include <stout/hashset.hpp>
24 #include <stout/option.hpp>
25 
26 namespace process {
27 namespace firewall {
28 
41 {
42 public:
44  virtual ~FirewallRule() {}
45 
59  const http::Request& request) = 0;
60 };
61 
62 
71 {
72 public:
74 
76 
78  const network::inet::Socket&,
79  const http::Request& request) override
80  {
81  if (paths.contains(request.url.path)) {
82  return http::Forbidden("Endpoint '" + request.url.path + "' is disabled");
83  }
84 
85  return None();
86  }
87 
88 private:
90 };
91 
92 } // namespace firewall {
93 } // namespace process {
94 
95 #endif // __PROCESS_FIREWALL_HPP__
Definition: option.hpp:29
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
URL url
Definition: http.hpp:544
std::string paths()
Definition: os.hpp:138
Option< http::Response > apply(const network::inet::Socket &, const http::Request &request) override
Verify rule by applying it to an HTTP request and its underlying socket connection.
Definition: firewall.hpp:77
Definition: http.hpp:533
std::string path
Definition: http.hpp:188
FirewallRule()
Definition: firewall.hpp:43
virtual ~FirewallRule()
Definition: firewall.hpp:44
~DisabledEndpointsFirewallRule() override
Definition: firewall.hpp:75
Definition: none.hpp:27
Definition: executor.hpp:48
A &#39;FirewallRule&#39; describes an interface which provides control over incoming HTTP requests while also...
Definition: firewall.hpp:40
Simple firewall rule to forbid any HTTP request to a path in the provided list of endpoints...
Definition: firewall.hpp:70
Try< Netlink< struct nl_sock > > socket(int protocol=NETLINK_ROUTE)
Definition: internal.hpp:91
virtual Option< http::Response > apply(const network::inet::Socket &socket, const http::Request &request)=0
Verify rule by applying it to an HTTP request and its underlying socket connection.
Definition: http.hpp:747