2022-03-24 05:23:34 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
2023-10-30 16:58:54 -05:00
|
|
|
* Copyright the Collabora Online contributors.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2023-11-09 12:23:00 -06:00
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2022-03-24 05:23:34 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Util.hpp>
|
|
|
|
#include <Poco/URI.h>
|
|
|
|
#include <Poco/Util/Application.h>
|
|
|
|
|
|
|
|
/// This class contains static methods to parse alias_groups and WOPI host and static containers to store the data from the coolwsd.xml
|
|
|
|
class HostUtil
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
/// Allowed/denied WOPI hosts, if any and if WOPI is enabled.
|
|
|
|
static Util::RegexListMatcher WopiHosts;
|
|
|
|
/// mapping of alias host and port to real host and port
|
|
|
|
static std::map<std::string, std::string> AliasHosts;
|
|
|
|
/// When group configuration is not defined only the firstHost gets access
|
|
|
|
static std::string FirstHost;
|
2022-06-09 01:09:54 -05:00
|
|
|
/// list of host (not aliases) in alias_groups
|
|
|
|
static std::set<std::string> hostList;
|
2022-03-24 05:23:34 -05:00
|
|
|
|
|
|
|
static bool WopiEnabled;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// parse wopi.storage.host
|
|
|
|
static void parseWopiHost(Poco::Util::LayeredConfiguration& conf);
|
|
|
|
|
|
|
|
/// parse wopi.storage.alias_groups.group
|
|
|
|
static void parseAliases(Poco::Util::LayeredConfiguration& conf);
|
|
|
|
|
|
|
|
/// if request uri is an alias, replace request uri host and port with
|
|
|
|
/// original hostname and port defined by group tag from coolwsd.xml
|
|
|
|
/// to avoid possibility of opening the same file as two if the WOPI host
|
|
|
|
/// is accessed using different aliases
|
|
|
|
static std::string getNewUri(const Poco::URI& uri);
|
|
|
|
|
|
|
|
/// add host to WopiHosts
|
|
|
|
static void addWopiHost(std::string host, bool allow);
|
|
|
|
|
|
|
|
static bool allowedWopiHost(const std::string& host);
|
|
|
|
|
|
|
|
static bool isWopiEnabled() { return WopiEnabled; }
|
2022-03-24 05:33:40 -05:00
|
|
|
|
|
|
|
/// replace the authority of aliashost to realhost if it matches
|
2023-05-23 15:55:59 -05:00
|
|
|
static const Poco::URI getNewLockedUri(const Poco::URI& uri);
|
2022-03-31 05:58:44 -05:00
|
|
|
|
|
|
|
static void setFirstHost(const Poco::URI& uri);
|
2022-03-24 05:23:34 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|