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

#include <library/cpp/tvmauth/checked_service_ticket.h>
#include <library/cpp/tvmauth/checked_user_ticket.h>
#include <library/cpp/tvmauth/ticket_status.h>

#include <util/datetime/base.h>
#include <util/generic/fwd.h>

namespace NTvmAuth::NUtils {
    TString Bin2base64url(TStringBuf buf);
    TString Base64url2bin(TStringBuf buf);

    TString SignCgiParamsForTvm(TStringBuf secret, TStringBuf ts, TStringBuf dstTvmId, TStringBuf scopes);
}

namespace NTvmAuth::NInternal {
    class TCanningKnife {
    public:
        static TCheckedServiceTicket::TImpl* GetS(TCheckedServiceTicket& t) {
            return t.Impl_.Release();
        }

        static TCheckedUserTicket::TImpl* GetU(TCheckedUserTicket& t) {
            return t.Impl_.Release();
        }

        static TMaybe<TInstant> GetExpirationTime(TStringBuf ticket);
    };
}