Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
URLRequestFilter.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/ContainersFwd.h"
7#include "Containers/StringFwd.h"
8#include "Containers/Map.h"
9
10namespace UE::Core
11{
12
13/**
14 * A filter that can used to restrict URL schemes and domains to known-safe values.
15 * Stores a map of schemes to domains: if the map is empty, no filtering is performed and any URL is allowed.
16 * Each key is a scheme (such as "https"). If a scheme is present, it will be allowed.
17 * Each value is an array of absolute domains or partial higher-level domains that are allowed for their scheme.
18 *
19 * Absolute domains do not start with a period and will be matched exactly with domains from the input URL,
20 * for example, "epicgames.com".
21 *
22 * Partial domains start with a period and will be matched with the ending of the input domain.
23 * Use these to allow all subdomains of the higher-level domain. For example, ".epicgames.com"
24 *
25 * To allow both an absolute domain and all of its subdomains, provide two entries in the array,
26 * one with the period prefix and one without. For example, "epicgames.com" and ".epicgames.com".
27 */
29{
30public:
31 using FRequestMap = TMap<const FString, const TArray<FString>>;
32
33 FURLRequestFilter() = default;
34
35 /**
36 * Initializes the allowlist map based on ini configs. Example syntax:
37 *
38 * [ConfigSectionRootName https]
39 * !AllowedDomains=ClearArray
40 * +AllowedDomains=epicgames.com
41 *
42 * [ConfigSectionRootName http]
43 * !AllowedDomains=ClearArray
44 * +AllowedDomains=epicgames.com
45 */
46 FURLRequestFilter(const TCHAR* ConfigSectionRootName, const FString& ConfigFileName);
47
48 /**
49 * Initializes the allowlist based on an explicit scheme/domain map
50 */
51 FURLRequestFilter(const FRequestMap& InAllowedRequests);
52 FURLRequestFilter(FRequestMap&& InAllowedRequests);
53
54 /**
55 * Matches InURL against the configued list of allowed URL schemes and domains. Returns true if the URL is allowed.
56 */
57 bool IsRequestAllowed(FStringView InURL) const;
58
59private:
61};
62
63}
FURLRequestFilter(const TCHAR *ConfigSectionRootName, const FString &ConfigFileName)
FURLRequestFilter(const FRequestMap &InAllowedRequests)
bool IsRequestAllowed(FStringView InURL) const
FURLRequestFilter(FRequestMap &&InAllowedRequests)
Definition Vector.h:40