27namespace http_field_parsers
186 const auto * token68 = get_if<authorization_value_t::token68_t>(
191 const auto unbase64_result =
193 if( !unbase64_result )
196 const std::string & username_password = *unbase64_result;
197 const auto first_colon = username_password.find(
':' );
198 if( std::string::npos == first_colon )
199 return make_unexpected(
201 if( 0u == first_colon )
205 username_password.substr( 0u, first_colon ),
206 username_password.substr( first_colon + 1u )
218 if( !opt_field_value )
223 if( !field_value_parse_result )
226 const auto & parsed_value = *field_value_parse_result;
227 if(
"basic" != parsed_value.auth_scheme )
292template<
typename Extra_Data >
359template<
typename Extra_Data >
Stuff related to value of Authorization HTTP-field.
const http_request_header_t & header() const noexcept
Get request header.
#define RESTINIO_NODISCARD
RESTINIO_NODISCARD expected_t< params_t, extraction_error_t > perform_extraction_attempt(const optional_t< string_view_t > opt_field_value)
extraction_error_t
Error codes for failures of extraction of basic authentification parameters.
@ not_basic_auth_scheme
Different authentification scheme found. Basic authentification scheme is expected.
@ token68_decode_error
Value of token68 parameter for basic authentification can't be decoded.
@ no_auth_http_field
There is no HTTP field with authentification parameters.
@ empty_username
Empty user name in username:password pair.
@ invalid_username_password_pair
Wrong format for username:password in decoded token68 parameter. Maybe there is no colon symbol.
@ illegal_http_field_value
The HTTP field with authentification parameters can't be parsed.
@ invalid_basic_auth_param
Invalid value of parameter for basic authentification scheme. The single parameter in the form of tok...
RESTINIO_NODISCARD string_view_t to_string_view(extraction_error_t what) noexcept
Helper function to get a string name of extraction_error enum.
RESTINIO_NODISCARD expected_t< params_t, extraction_error_t > try_extract_params(const authorization_value_t &http_field)
Helper function for getting parameters of basic authentification from an already parsed HTTP-field.
expected_t< std::string, decoding_error_t > try_decode(string_view_t str)
nonstd::string_view string_view_t
http_field_t
C++ enum that repeats nodejs c-style enum.
nonstd::expected< T, E > expected_t
Tools for working with the value of Authorization HTTP-field.
static RESTINIO_NODISCARD expected_t< authorization_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Authorization HTTP-field.
Parameters for basic authentification.
std::string username
Name of a user.
std::string password
Password for a user.