6#include <userver/server/request/request_context.hpp>
7#include <userver/utils/strong_typedef.hpp>
9#include <userver/server/auth/user_env.hpp>
10#include <userver/server/auth/user_id.hpp>
11#include <userver/server/auth/user_provider.hpp>
12#include <userver/server/auth/user_scopes.hpp>
14USERVER_NAMESPACE_BEGIN
16namespace server::handlers::auth {
20namespace server::auth {
22class UserAuthInfo
final {
24 using Ticket = utils::NonLoggable<
class TicketTag, std::string>;
26 UserAuthInfo(UserId default_id, UserEnv env, UserProvider provider);
27 UserAuthInfo(UserId default_id, Ticket user_ticket, UserEnv env, UserProvider provider);
29 UserAuthInfo(UserId default_id, UserIds ids, UserScopes scopes, UserEnv env, UserProvider provider);
39 UserId GetDefaultUserId()
const;
40 const UserIds& GetUserIds()
const;
41 const std::optional<UserScopes>& GetUserScopesOptional()
const;
42 const std::optional<Ticket>& GetTicketOptional()
const;
43 UserEnv GetUserEnv()
const {
return user_env_; }
44 UserProvider GetUserProvider()
const {
return user_provider_; }
48 static void Set(server::
request::RequestContext& request_context, UserAuthInfo&& info);
52 std::optional<UserScopes> scopes_;
53 std::optional<Ticket> user_ticket_;
55 UserProvider user_provider_;
58const UserAuthInfo& GetUserAuthInfo(
const server::
request::RequestContext& request_context);
60const std::optional<UserAuthInfo> GetUserAuthInfoOpt(
const server::
request::RequestContext& request_context);