|
xentara-plugin v2.1
The Xentara Plugin Framework
|
A pattern used to match HTTP request origins for CORS (Cross-Origin Resource Sharing) More...
#include <xentara/security/CorsOriginPattern.hpp>
Public Member Functions | |
| CorsOriginPattern ()=default | |
| Default constructor. | |
| template<std::convertible_to< std::string_view > Origin> | |
| CorsOriginPattern (const Origin &origin) | |
| Constructor for a pattern that matches a single origin. | |
| CorsOriginPattern (std::string &&origin) | |
| Move-Constructor for a pattern that matches a single origin. | |
| CorsOriginPattern (std::regex &&pattern) | |
| Move-Constructor for a pattern that matches a regular expression. | |
| operator bool () const noexcept | |
| Determines if the pattern is not a default constructed dummy pattern. | |
| auto | matches (std::string_view origin) const noexcept -> bool |
| Checks whether the pattern matches an origin. | |
| auto | load (utils::json::decoder::Value &value) -> void |
| Loads the pattern from a configuration value. | |
Static Public Member Functions | |
| static auto | wildcard () -> CorsOriginPattern |
| Creates a pattern than matches all valid origins. | |
| static auto | checkOriginString (std::string_view origin) -> utils::eh::expected< void, std::string_view > |
| Checks whether a string is a legal origin. | |
A pattern used to match HTTP request origins for CORS (Cross-Origin Resource Sharing)
|
default |
Default constructor.
This constructor constructs a pattern that matches no origins.
| xentara::security::CorsOriginPattern::CorsOriginPattern | ( | const Origin & | origin | ) |
Constructor for a pattern that matches a single origin.
| origin | The origin to allow. Must be a valid origin. Valid origins are URLs with no user information and no path, query, or fragment parts. The string “null” is also a valid origin. You can use checkOriginString() to check the origin for validity. |
| std::invalid_argument | origin is not a valid origin |
| xentara::security::CorsOriginPattern::CorsOriginPattern | ( | std::string && | origin | ) |
Move-Constructor for a pattern that matches a single origin.
| origin | The origin to allow. Must be a valid origin. Valid origins are URLs with no user information and no path, query, or fragment parts. The string “null” is also a valid origin. You can use checkOriginString() to check the origin for validity. |
| std::invalid_argument | origin is an empty string |
| xentara::security::CorsOriginPattern::CorsOriginPattern | ( | std::regex && | pattern | ) |
Move-Constructor for a pattern that matches a regular expression.
|
static |
Checks whether a string is a legal origin.
| origin | The string to check |
| auto xentara::security::CorsOriginPattern::load | ( | utils::json::decoder::Value & | value | ) | -> void |
Loads the pattern from a configuration value.
| value | The value to load the configuration from |
| std::runtime_error | The configuration is not valid, or another error occurred. |
|
noexcept |
Checks whether the pattern matches an origin.
|
explicitnoexcept |
Determines if the pattern is not a default constructed dummy pattern.
|
static |
Creates a pattern than matches all valid origins.