|
xentara-plugin v2.1
The Xentara Plugin Framework
|
Server-side authentication configuration for an HTTP based service. More...
#include <xentara/security/HttpConfig.hpp>
Public Member Functions | |
| HttpConfig () | |
| Constructor for a default configuration. | |
| constexpr auto | realm () const noexcept -> std::string_view |
| Gets the realm. | |
| constexpr auto | schemes () const noexcept -> std::span< const std::string > |
| Gets the list of allowed schemes. | |
| constexpr auto | scope () const noexcept -> const Oauth2Scope & |
| Gets the OAuth 2.0 scope. | |
| constexpr auto | allowedOrigins () const noexcept -> std::span< const CorsOriginPattern > |
| Gets the list of allowed CORS origins. | |
| constexpr auto | allowCorsCredentials () const noexcept -> bool |
| Checks whether CORS requests are allowed to include credentials. | |
| auto | setRealm (std::string realm) -> void |
| Sets the realm. | |
| auto | setSchemes (std::vector< std::string > schemes) -> void |
| Sets the list of supported HTTP authentication schemes. | |
| auto | setScheme (std::string scheme) -> void |
| Sets the list of supported HTTP authentication schemes to a single scheme. | |
| auto | setScope (Oauth2Scope scope) -> void |
| Sets the required OAuth 2.0 scope. | |
| auto | setAllowedOrigins (std::vector< CorsOriginPattern > allowedOrigins) -> void |
| Sets the list of allowed CORS origins. | |
| auto | setAllowCorsCredentials (bool allowCredentials) -> void |
| Specifies whether CORS requests should be allowed to include credentials. | |
| auto | loadAuthentication (utils::json::decoder::Value &value, config::Context &context) -> void |
| Loads the authentication configuration from a JSON value. | |
| auto | loadCors (utils::json::decoder::Value &value, config::Context &context) -> void |
| Loads the CORS (Cross-Origin Resource Sharing) configuration from a JSON value. | |
Static Public Member Functions | |
| static auto | checkRealmString (std::string_view string) -> utils::eh::expected< void, std::string_view > |
| Checks whether a string is a legal HTTP realm string. | |
Deprecated Functions | |
| auto | load (utils::json::decoder::Value &value, config::Context &context) -> void |
| deprecated Loads the authentication configuration from a JSON value. | |
Server-side authentication configuration for an HTTP based service.
| xentara::security::HttpConfig::HttpConfig | ( | ) |
Constructor for a default configuration.
The default authentication configuration allows OAuth 2.0 authentication using the authentication realm “Xentara” and the default scope configured in the global Xentara OAuth 2.0 configuration.
The default CORS configuration allows all origins.
|
constexprnoexcept |
Checks whether CORS requests are allowed to include credentials.
|
constexprnoexcept |
Gets the list of allowed CORS origins.
|
static |
Checks whether a string is a legal HTTP realm string.
| string | The string to check |
| auto xentara::security::HttpConfig::load | ( | utils::json::decoder::Value & | value, |
| config::Context & | context | ||
| ) | -> void |
deprecated Loads the authentication configuration from a JSON value.
| auto xentara::security::HttpConfig::loadAuthentication | ( | utils::json::decoder::Value & | value, |
| config::Context & | context | ||
| ) | -> void |
Loads the authentication configuration from a JSON value.
Normally, the name of the configuration parameter containing the authentication configuration should be called “authentication”. If necessary, a different name can be used, however, like “HTTPAuthentication”.
The configuration parameter for the authentication configuration can generally be optional. If the parameter is not specified in the configuration, the default authentication configuration created by the default constructor should be used.
| value | The value to load the authentication parameters from. |
| context | The configuration context. |
| std::runtime_error | The configuration is not valid, or another error occurred. |
| auto xentara::security::HttpConfig::loadCors | ( | utils::json::decoder::Value & | value, |
| config::Context & | context | ||
| ) | -> void |
Loads the CORS (Cross-Origin Resource Sharing) configuration from a JSON value.
Normally, the name of the configuration parameter containing the authentication configuration should be called “CORS”. If necessary, a different name can be used, however, like “HTTPCORS”.
The configuration parameter for the CORS configuration can generally be optional. If the parameter is not specified in the configuration, the default CORS configuration created by the default constructor should be used.
| value | The value to load the CORS parameters from. |
| context | The configuration context. |
| std::runtime_error | The configuration is not valid, or another error occurred. |
|
constexprnoexcept |
Gets the realm.
|
constexprnoexcept |
Gets the list of allowed schemes.
|
constexprnoexcept |
Gets the OAuth 2.0 scope.
| auto xentara::security::HttpConfig::setAllowCorsCredentials | ( | bool | allowCredentials | ) | -> void |
Specifies whether CORS requests should be allowed to include credentials.
| allowCredentials | Whether responses to CORS requests should include “Access-Control-Allow-Credentials: true”. |
| auto xentara::security::HttpConfig::setAllowedOrigins | ( | std::vector< CorsOriginPattern > | allowedOrigins | ) | -> void |
Sets the list of allowed CORS origins.
| allowedOrigins | The list of allowed origins. If you pass an empty list, no origins will be allowed. |
| auto xentara::security::HttpConfig::setRealm | ( | std::string | realm | ) | -> void |
Sets the realm.
| realm | The realm. Must be a valid realm string. You can use checkRealmString() to check the realm string for validity. |
| std::invaid_parameter | realm is not a valid HTTP realm string. |
| auto xentara::security::HttpConfig::setScheme | ( | std::string | scheme | ) | -> void |
Sets the list of supported HTTP authentication schemes to a single scheme.
| scheme | The scheme. Must be a supported HTTP authentication scheme. The supported schemes are “Bearer” for OAuth 2.0 authentication using bearer tokens, and “Basic” for HTTP user/password authentication. |
| std::invaid_parameter | scheme is not a supported HTTP authentication scheme. |
| auto xentara::security::HttpConfig::setSchemes | ( | std::vector< std::string > | schemes | ) | -> void |
Sets the list of supported HTTP authentication schemes.
| schemes | The list of supported schemes. Each scheme must be a supported HTTP authentication scheme. The supported schemes are “Bearer” for OAuth 2.0 authentication using bearer tokens, and “Basic” for HTTP user/password authentication. |
| std::invaid_parameter | schemes contains a string that is not a supported HTTP authentication scheme. |
| auto xentara::security::HttpConfig::setScope | ( | Oauth2Scope | scope | ) | -> void |
Sets the required OAuth 2.0 scope.
| scope | The scope to use, or a default constructed Oauth2Scope object to use the default scope configured in the global Xentara OAuth 2.0 configuration. |