aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/checked_user_ticket.h
blob: 2c3d712e273a8c0a0e1c55e44d79c1d3854e70fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once 
 
#include "ticket_status.h" 
#include "type.h" 
#include "utils.h" 
 
#include <util/generic/ptr.h> 
 
namespace NTvmAuth::NInternal { 
    class TCanningKnife; 
} 
 
namespace NTvmAuth { 
    /*! 
     * BlackboxEnv describes environment of Passport: 
     * https://wiki.yandex-team.ru/passport/tvm2/user-ticket/#0-opredeljaemsjasokruzhenijami 
     */ 
    enum class EBlackboxEnv: ui8 { 
        Prod, 
        Test, 
        ProdYateam, 
        TestYateam, 
        Stress 
    }; 
 
    /*! 
     * UserTicket contains only valid users. 
     * Details: https://wiki.yandex-team.ru/passport/tvm2/user-ticket/#chtoestvusertickete 
     */ 
    class TCheckedUserTicket { 
    public: 
        class TImpl; 
 
        TCheckedUserTicket(THolder<TImpl> impl); 
        TCheckedUserTicket(TCheckedUserTicket&&); 
        ~TCheckedUserTicket(); 
 
        TCheckedUserTicket& operator=(TCheckedUserTicket&&); 
 
        /*! 
         * @return True value if ticket parsed and checked successfully 
         */ 
        explicit operator bool() const; 
 
        /*! 
         * Never empty 
         * @return UIDs of users listed in ticket 
         */ 
        const TUids& GetUids() const; 
 
        /*! 
         * Maybe 0 
         * @return Default user in ticket 
         */ 
        TUid GetDefaultUid() const; 
 
        /*! 
         * Scopes inherited from credential - never empty 
         * @return Newly constructed vector of scopes 
         */ 
        const TScopes& GetScopes() const; 
 
        /*! 
         * Check if scope presented in ticket 
         */ 
        bool HasScope(TStringBuf scopeName) const; 
 
        /*! 
         * @return Ticket check status 
         */ 
        ETicketStatus GetStatus() const; 
 
        /*! 
         * DebugInfo is human readable data for debug purposes 
         * @return Serialized ticket 
         */ 
        TString DebugInfo() const; 
 
        /*! 
         * Env of user 
         */ 
        EBlackboxEnv GetEnv() const; 
 
    public: // for python binding 
        TCheckedUserTicket() = default; 
 
    private: 
        THolder<TImpl> Impl_; 
        friend class NInternal::TCanningKnife; 
    }; 
}