Drop the AGPL license in favor of a source-available license. See the blog post [1] for details. [1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2018-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string_view>
|
|
#include <functional>
|
|
#include <optional>
|
|
#include <fmt/core.h>
|
|
|
|
#include <seastar/core/sstring.hh>
|
|
|
|
#include "seastarx.hh"
|
|
|
|
namespace auth {
|
|
|
|
class role_or_anonymous final {
|
|
public:
|
|
std::optional<sstring> name{};
|
|
|
|
role_or_anonymous() = default;
|
|
role_or_anonymous(std::string_view name) : name(name) {
|
|
}
|
|
friend bool operator==(const role_or_anonymous&, const role_or_anonymous&) noexcept = default;
|
|
};
|
|
|
|
bool is_anonymous(const role_or_anonymous&) noexcept;
|
|
|
|
}
|
|
|
|
namespace std {
|
|
|
|
template <>
|
|
struct hash<auth::role_or_anonymous> {
|
|
size_t operator()(const auth::role_or_anonymous& mr) const {
|
|
return hash<std::optional<sstring>>()(mr.name);
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
template <> struct fmt::formatter<auth::role_or_anonymous> {
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
auto format(const auth::role_or_anonymous&, fmt::format_context& ctx) const -> decltype(ctx.out());
|
|
};
|