bes Updated for version 3.20.13
AllowedHosts.h
1// AllowedHosts.h
2
3// -*- mode: c++; c-basic-offset:4 -*-
4
5// This file is part of the OPeNDAP Back-End Server (BES)
6// and creates a set of allowed hosts that may be
7// accessed by the server as part of it's routine operation.
8
9// Copyright (c) 2018 OPeNDAP, Inc.
10// Author: Nathan D. Potter <ndp@opendap.org>
11//
12// This library is free software; you can redistribute it and/or
13// modify it under the terms of the GNU Lesser General Public
14// License as published by the Free Software Foundation; either
15// version 2.1 of the License, or (at your option) any later version.
16//
17// This library is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20// Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public
23// License along with this library; if not, write to the Free Software
24// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25//
26// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
27
28// Authors:
29// ndp Nathan D. Potter <ndp@opendap.org>
30
31#ifndef I_AllowedHosts_H
32#define I_AllowedHosts_H 1
33
34#include <memory>
35#include <string>
36#include <vector>
37
38#include "url_impl.h"
39
40#define ALLOWED_HOSTS_BES_KEY "AllowedHosts"
41
42namespace http {
43
55private:
56 static AllowedHosts *d_instance;
57 std::vector<std::string> d_allowed_hosts;
58
59 static void initialize_instance();
60 static void delete_instance();
61
63
64 bool check(const std::string &url);
65
66public:
67 virtual ~AllowedHosts() {}
68
69 static AllowedHosts *theHosts();
70
71 bool is_allowed(std::shared_ptr<http::url> candidate_url);
72 bool is_allowed(std::shared_ptr<http::url> candidate_url, std::string &whynot);
73
74};
75
76} // namespace bes
77
78#endif // I_AllowedHosts_H
79
Can a given URL be dereferenced given the BES's configuration?
Definition: AllowedHosts.h:54
bool is_allowed(std::shared_ptr< http::url > candidate_url)
static AllowedHosts * theHosts()
Static accessor for the singleton.
Definition: AllowedHosts.cc:69
utility class for the HTTP catalog module
Definition: AllowedHosts.cc:55