| |
| |
| |
| |
| |
|
|
| #ifndef MAMBA_SPECS_AUTHENTICATION_INFO_HPP |
| #define MAMBA_SPECS_AUTHENTICATION_INFO_HPP |
|
|
| #include <functional> |
| #include <optional> |
| #include <string> |
| #include <string_view> |
| #include <unordered_map> |
| #include <variant> |
|
|
| #include "mamba/util/weakening_map.hpp" |
|
|
| namespace mamba::specs |
| { |
| |
| struct BasicHTTPAuthentication |
| { |
| std::string user; |
| std::string password; |
| }; |
|
|
| auto operator==(const BasicHTTPAuthentication& a, const BasicHTTPAuthentication& b) -> bool; |
| auto operator!=(const BasicHTTPAuthentication& a, const BasicHTTPAuthentication& b) -> bool; |
|
|
| |
| struct BearerToken |
| { |
| std::string token; |
| }; |
|
|
| auto operator==(const BearerToken& a, const BearerToken& b) -> bool; |
| auto operator!=(const BearerToken& a, const BearerToken& b) -> bool; |
|
|
| |
| struct CondaToken |
| { |
| std::string token; |
| }; |
|
|
| auto operator==(const CondaToken& a, const CondaToken& b) -> bool; |
| auto operator!=(const CondaToken& a, const CondaToken& b) -> bool; |
|
|
| using AuthenticationInfo = std::variant<BasicHTTPAuthentication, BearerToken, CondaToken>; |
|
|
| |
| |
| |
| struct URLWeakener |
| { |
| |
| |
| |
| |
| |
| [[nodiscard]] auto make_first_key(std::string_view key) const -> std::string; |
|
|
| |
| |
| |
| |
| |
| |
| [[nodiscard]] auto weaken_key(std::string_view key) const -> std::optional<std::string_view>; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| using AuthenticationDataBase = util:: |
| weakening_map<std::unordered_map<std::string, AuthenticationInfo>, URLWeakener>; |
| } |
|
|
| template <> |
| struct std::hash<mamba::specs::BasicHTTPAuthentication> |
| { |
| auto operator()(const mamba::specs::BasicHTTPAuthentication& auth) const -> std::size_t; |
| }; |
|
|
| template <> |
| struct std::hash<mamba::specs::BearerToken> |
| { |
| auto operator()(const mamba::specs::BearerToken& auth) const -> std::size_t; |
| }; |
|
|
| template <> |
| struct std::hash<mamba::specs::CondaToken> |
| { |
| auto operator()(const mamba::specs::CondaToken& auth) const -> std::size_t; |
| }; |
|
|
| #endif |
|
|