blob: 26202f283e8bece55dde497153a8752e5bd42cbd (
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
|
#pragma once
#include <library/cpp/tvmauth/src/protos/ticket2.pb.h>
#include <library/cpp/tvmauth/src/protos/tvm_keys.pb.h>
#include <library/cpp/tvmauth/src/rw/keys.h>
#include <library/cpp/tvmauth/type.h>
#include <library/cpp/tvmauth/deprecated/service_context.h>
#include <library/cpp/charset/ci_string.h>
#include <library/cpp/string_utils/secret_string/secret_string.h>
#include <util/generic/maybe.h>
#include <string>
namespace NTvmAuth {
using TServiceTicketImplPtr = THolder<TCheckedServiceTicket::TImpl>;
class TCheckedServiceTicket::TImpl {
public:
explicit operator bool() const;
TTvmId GetDst() const;
TTvmId GetSrc() const;
const TScopes& GetScopes() const;
bool HasScope(TStringBuf scopeName) const;
ETicketStatus GetStatus() const;
time_t GetExpirationTime() const;
TString DebugInfo() const;
TMaybe<TUid> GetIssuerUid() const;
void SetStatus(ETicketStatus status);
/*!
* Constructor for creation invalid ticket storing error status in TServiceContext
* @param status
* @param protobufTicket
*/
TImpl(ETicketStatus status, ticket2::Ticket&& protobufTicket);
static TServiceTicketImplPtr CreateTicketForTests(ETicketStatus status,
TTvmId src,
TMaybe<TUid> issuerUid);
private:
ETicketStatus Status_;
ticket2::Ticket ProtobufTicket_;
mutable TScopes CachedScopes_;
mutable TString CachedDebugInfo_;
};
class TServiceContext::TImpl {
public:
TImpl(TStringBuf secretBase64, TTvmId selfTvmId, TStringBuf tvmKeysResponse);
TImpl(TTvmId selfTvmId, TStringBuf tvmKeysResponse);
TImpl(TStringBuf secretBase64);
void ResetKeys(TStringBuf tvmKeysResponse);
TServiceTicketImplPtr Check(TStringBuf ticketBody, const TServiceContext::TCheckFlags& flags = {}) const;
TString SignCgiParamsForTvm(TStringBuf ts, TStringBuf dst, TStringBuf scopes = TStringBuf()) const;
const NRw::TPublicKeys& GetKeys() const { // for tests
return Keys_;
}
private:
static TString ParseSecret(TStringBuf secretBase64);
NRw::TPublicKeys Keys_;
const NSecretString::TSecretString Secret_;
const TTvmId SelfTvmId_ = 0;
::google::protobuf::LogSilencer LogSilencer_;
};
}
|