xentara-plugin v2.0.4
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. | |
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 | load (utils::json::decoder::Value &value, config::Context &context) -> void |
Loads the 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. | |
Server-side authentication configuration for an HTTP based service.
xentara::security::HttpConfig::HttpConfig | ( | ) |
Constructor for a default configuration.
The default configuration allows OAuth 2.0 authentication using the authentication realm “Xentara” and the default scope configured in the global Xentara OAuth 2.0 configuration.
|
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 |
Loads the configuration from a JSON value.
Normally, the name of the configuration parameter containing the configuration should be called “authentication”, because this object contains information about the HTTP authentication configuration. If necessary, a different name can be used, however, like “HTTPAuthentication”.
The configuration parameter for the configuration can generally be optional. If the parameter is not specified in the configuration, the default configuration created by the default constructor should be used.
value | The value to load the 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::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. |