xentara-plugin v2.0.3
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::security::Oauth2Scope Class Referencefinal

An OAuth 2.0 scope, consisting of a list of scope strings. More...

#include <xentara/security/Oauth2Scope.hpp>

Public Member Functions

 Oauth2Scope ()=default
 Default constructor.
 
 Oauth2Scope (std::vector< std::string > scopeStrings)
 Constructor that constructs a valid scope from a list of scope strings.
 
 operator bool () const noexcept
 Determines if the scope contains any scope strings.
 
internal auto operator== (const Oauth2Scope &scope) const noexcept -> bool=default
 Compares two scopes to check whether they are the same.
 
auto load (utils::json::decoder::Value &value) -> void
 Loads the scope from a configuration value.
 
template<utils::tools::CharType Char, typename CharTraits = std::char_traits<Char>>
auto toBasicString () const -> std::basic_string< Char, CharTraits >
 Converts the scope to a string.
 
auto toString () const -> std::string
 Converts the scope to a string of type char.
 
auto toWString () const -> std::wstring
 Converts the scope to a string of type wchar_t.
 
auto toU8String () const -> std::u8string
 Converts the scope to a string of type char8_t.
 
auto toU16String () const -> std::u16string
 Converts the scope to a string of type char16_t.
 
auto toU32String () const -> std::u32string
 Converts the scope to a string of type char32_t.
 

Static Public Member Functions

static internal auto checkScopeString (std::string_view string) -> utils::eh::expected< void, std::string_view >
 Checks whether a string is a legal OAuth 2.0 scope string.
 

Detailed Description

An OAuth 2.0 scope, consisting of a list of scope strings.

Constructor & Destructor Documentation

◆ Oauth2Scope() [1/2]

xentara::security::Oauth2Scope::Oauth2Scope ( )
default

Default constructor.

This constructor constructs an empty scope that contains no scope strings. If you use such a scope, the default scope configured in the Xentara OAuth 2.0 configuration will be used.

◆ Oauth2Scope() [2/2]

xentara::security::Oauth2Scope::Oauth2Scope ( std::vector< std::string scopeStrings)

Constructor that constructs a valid scope from a list of scope strings.

Parameters
scopeStringsThe list of scope strings. Must be a non-empty list of valid OAuth 2.0 scope strings. You can use checkScopeString() to check the scope strings for validity. The order of the scope strings is not relevant, and duplicate scope strings are removed.
Exceptions
std::invalid_argumentscopeStrings is an empty list.
std::invalid_argumentscopeStrings contains a string that is not a valid OAuth 2.0 scope string.

Member Function Documentation

◆ checkScopeString()

static internal auto xentara::security::Oauth2Scope::checkScopeString ( std::string_view  string) -> utils::eh::expected< void, std::string_view >
static

Checks whether a string is a legal OAuth 2.0 scope string.

Parameters
stringThe string to check
Returns
A valid expected value, or an (English) error string describing the exact problem, suitable for display to the user.

◆ load()

auto xentara::security::Oauth2Scope::load ( utils::json::decoder::Value value) -> void

Loads the scope from a configuration value.

Parameters
valueThe value to load the configuration from
Exceptions
std::runtime_errorThe configuration is not valid, or another error occurred.

◆ operator bool()

xentara::security::Oauth2Scope::operator bool ( ) const
explicitnoexcept

Determines if the scope contains any scope strings.

Returns
Returns true if the object contains a valid scope consisting of at least one scope string. Returns false if the contains no scope strings, and the default scope configured in the Xentara OAuth 2.0 configuration will be used instead.

◆ operator==()

internal auto xentara::security::Oauth2Scope::operator== ( const Oauth2Scope scope) const -> bool=default
defaultnoexcept

Compares two scopes to check whether they are the same.

◆ toBasicString()

template<utils::tools::CharType Char, typename CharTraits >
auto xentara::security::Oauth2Scope::toBasicString ( ) const -> std::basic_string<Char, CharTraits>

Converts the scope to a string.

Returns
The scope as a string, formatted in the manner required for the HTTP “WWW-Authenticate” header.

◆ toString()

auto xentara::security::Oauth2Scope::toString ( ) const -> std::string

Converts the scope to a string of type char.

Returns
The scope as a string, formatted in the manner required for the HTTP “WWW-Authenticate” header.

◆ toU16String()

auto xentara::security::Oauth2Scope::toU16String ( ) const -> std::u16string

Converts the scope to a string of type char16_t.

Returns
The scope as a string, formatted in the manner required for the HTTP “WWW-Authenticate” header.

◆ toU32String()

auto xentara::security::Oauth2Scope::toU32String ( ) const -> std::u32string

Converts the scope to a string of type char32_t.

Returns
The scope as a string, formatted in the manner required for the HTTP “WWW-Authenticate” header.

◆ toU8String()

auto xentara::security::Oauth2Scope::toU8String ( ) const -> std::u8string

Converts the scope to a string of type char8_t.

Returns
The scope as a string, formatted in the manner required for the HTTP “WWW-Authenticate” header.

◆ toWString()

auto xentara::security::Oauth2Scope::toWString ( ) const -> std::wstring

Converts the scope to a string of type wchar_t.

Returns
The scope as a string, formatted in the manner required for the HTTP “WWW-Authenticate” header.