aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/checked_service_ticket.h
blob: cf4c5c43e3f64bbe4fd9ac6d57814fb131eccd3c (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
#pragma once

#include "ticket_status.h"
#include "type.h"
#include "utils.h"

#include <util/generic/ptr.h>

namespace NTvmAuth::NInternal {
    class TCanningKnife;
}

namespace NTvmAuth {
    class TCheckedServiceTicket {
    public:
        class TImpl;

        TCheckedServiceTicket(THolder<TImpl> impl);
        TCheckedServiceTicket(TCheckedServiceTicket&& o);
        ~TCheckedServiceTicket();

        TCheckedServiceTicket& operator=(TCheckedServiceTicket&&);

        /*!
         * @return True value if ticket parsed and checked successfully
         */
        explicit operator bool() const;

        /*!
         * You should check src with your ACL
         * @return TvmId of request source
         */
        TTvmId GetSrc() const;

        /*!
         * @return Ticket check status
         */
        ETicketStatus GetStatus() const;

        /*!
         * DebugInfo is human readable data for debug purposes
         * @return Serialized ticket
         */
        TString DebugInfo() const;

        /*!
         * IssuerUID is UID of developer who is debuging something,
         * so he(she) issued ServiceTicket with his(her) ssh-sign:
         * it is grant_type=sshkey in tvm-api.
         * https://wiki.yandex-team.ru/passport/tvm2/debug/#sxoditvapizakrytoeserviceticketami
         * @return uid
         */
        TMaybe<TUid> GetIssuerUid() const;

    public: // for python binding
        TCheckedServiceTicket() = default;

    private:
        THolder<TImpl> Impl_;
        friend class NInternal::TCanningKnife;
    };

    namespace NBlackboxTvmId {
        const TStringBuf Prod = "222";
        const TStringBuf Test = "224";
        const TStringBuf ProdYateam = "223";
        const TStringBuf TestYateam = "225";
        const TStringBuf Stress = "226";
        const TStringBuf Mimino = "239";
    }
}