/* * Copyright (C) 2018-present ScyllaDB */ /* * SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0 */ #pragma once #include #include #include #include #include #include #include #include "seastarx.hh" namespace auth { enum class authentication_option { password, hashed_password, options }; } template <> struct fmt::formatter : fmt::formatter { template auto format(const auth::authentication_option a, FormatContext& ctx) const { using enum auth::authentication_option; switch (a) { case password: return formatter::format("PASSWORD", ctx); case hashed_password: return formatter::format("HASHED PASSWORD", ctx); case options: return formatter::format("OPTIONS", ctx); } std::abort(); } }; namespace auth { using authentication_option_set = std::unordered_set; using custom_options = std::unordered_map; struct password_option { sstring password; }; /// Used exclusively for restoring roles. struct hashed_password_option { sstring hashed_password; }; struct authentication_options final { std::optional> credentials; std::optional options; }; inline bool any_authentication_options(const authentication_options& aos) noexcept { return aos.options || aos.credentials; } class unsupported_authentication_option : public std::invalid_argument { public: explicit unsupported_authentication_option(authentication_option k) : std::invalid_argument(format("The {} option is not supported.", k)) { } }; }