aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/deprecated
diff options
context:
space:
mode:
authorkomels <komels@yandex-team.ru>2022-04-14 13:10:53 +0300
committerkomels <komels@yandex-team.ru>2022-04-14 13:10:53 +0300
commit21c9b0e6b039e9765eb414c406c2b86e8cea6850 (patch)
treef40ebc18ff8958dfbd189954ad024043ca983ea5 /library/cpp/tvmauth/deprecated
parent9a4effa852abe489707139c2b260dccc6f4f9aa9 (diff)
downloadydb-21c9b0e6b039e9765eb414c406c2b86e8cea6850.tar.gz
Final part on compatibility layer: LOGBROKER-7215
ref:777c67aadbf705d19034a09a792b2df61ba53697
Diffstat (limited to 'library/cpp/tvmauth/deprecated')
-rw-r--r--library/cpp/tvmauth/deprecated/README.md2
-rw-r--r--library/cpp/tvmauth/deprecated/service_context.cpp37
-rw-r--r--library/cpp/tvmauth/deprecated/service_context.h63
-rw-r--r--library/cpp/tvmauth/deprecated/user_context.cpp20
-rw-r--r--library/cpp/tvmauth/deprecated/user_context.h30
5 files changed, 152 insertions, 0 deletions
diff --git a/library/cpp/tvmauth/deprecated/README.md b/library/cpp/tvmauth/deprecated/README.md
new file mode 100644
index 0000000000..d9ea09c3c0
--- /dev/null
+++ b/library/cpp/tvmauth/deprecated/README.md
@@ -0,0 +1,2 @@
+Please don't use this part of library directly.
+Please use [TTvmClient](https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/tvmauth/README.md) instead.
diff --git a/library/cpp/tvmauth/deprecated/service_context.cpp b/library/cpp/tvmauth/deprecated/service_context.cpp
new file mode 100644
index 0000000000..24822a9d53
--- /dev/null
+++ b/library/cpp/tvmauth/deprecated/service_context.cpp
@@ -0,0 +1,37 @@
+#include <library/cpp/tvmauth/checked_service_ticket.h>
+#include <library/cpp/tvmauth/src/service_impl.h>
+
+namespace NTvmAuth {
+ static const char* EX_MSG = "ServiceContext already moved out";
+
+ TServiceContext::TServiceContext(TStringBuf secretBase64, TTvmId selfTvmId, TStringBuf tvmKeysResponse)
+ : Impl_(MakeHolder<TImpl>(secretBase64, selfTvmId, tvmKeysResponse))
+ {
+ }
+
+ TServiceContext::TServiceContext(TServiceContext&& o) = default;
+ TServiceContext& TServiceContext::operator=(TServiceContext&& o) = default;
+ TServiceContext::~TServiceContext() = default;
+
+ TServiceContext TServiceContext::CheckingFactory(TTvmId selfTvmId, TStringBuf tvmKeysResponse) {
+ TServiceContext c;
+ c.Impl_ = MakeHolder<TImpl>(selfTvmId, tvmKeysResponse);
+ return c;
+ }
+
+ TServiceContext TServiceContext::SigningFactory(TStringBuf secretBase64) {
+ TServiceContext c;
+ c.Impl_ = MakeHolder<TImpl>(secretBase64);
+ return c;
+ }
+
+ TCheckedServiceTicket TServiceContext::Check(TStringBuf ticketBody) const {
+ Y_ENSURE(Impl_, EX_MSG);
+ return Impl_->Check(ticketBody);
+ }
+
+ TString TServiceContext::SignCgiParamsForTvm(TStringBuf ts, TStringBuf dst, TStringBuf scopes) const {
+ Y_ENSURE(Impl_, EX_MSG);
+ return Impl_->SignCgiParamsForTvm(ts, dst, scopes);
+ }
+}
diff --git a/library/cpp/tvmauth/deprecated/service_context.h b/library/cpp/tvmauth/deprecated/service_context.h
new file mode 100644
index 0000000000..bc14d381b2
--- /dev/null
+++ b/library/cpp/tvmauth/deprecated/service_context.h
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <library/cpp/tvmauth/checked_service_ticket.h>
+
+#include <util/generic/ptr.h>
+
+namespace NTvmAuth {
+ class TServiceContext: public TAtomicRefCount<TServiceContext> {
+ public:
+ /*!
+ * Create service context. Serivce contexts are used to store TVM keys and parse service tickets.
+ * @param selfTvmId
+ * @param secretBase64
+ * @param tvmKeysResponse
+ */
+ TServiceContext(TStringBuf secretBase64, TTvmId selfTvmId, TStringBuf tvmKeysResponse);
+ TServiceContext(TServiceContext&&);
+ ~TServiceContext();
+
+ /*!
+ * Create service context only for checking service tickets
+ * \param[in] selfTvmId
+ * \param[in] tvmKeysResponse
+ * \return
+ */
+ static TServiceContext CheckingFactory(TTvmId selfTvmId, TStringBuf tvmKeysResponse);
+
+ /*!
+ * Create service context only for signing HTTP request to TVM-API
+ * \param[in] secretBase64
+ * \return
+ */
+ static TServiceContext SigningFactory(TStringBuf secretBase64);
+
+ TServiceContext& operator=(TServiceContext&&);
+
+ /*!
+ * Parse and validate service ticket body then create TCheckedServiceTicket object.
+ * @param ticketBody
+ * @return TCheckedServiceTicket object
+ */
+ TCheckedServiceTicket Check(TStringBuf ticketBody) const;
+
+ /*!
+ * Sign params for TVM API
+ * @param ts Param 'ts' of request to TVM
+ * @param dst Param 'dst' of request to TVM
+ * @param scopes Param 'scopes' of request to TVM
+ * @return Signed string
+ */
+ TString SignCgiParamsForTvm(TStringBuf ts, TStringBuf dst, TStringBuf scopes = TStringBuf()) const;
+
+ class TImpl;
+
+ private:
+ TServiceContext() = default;
+
+ private:
+ THolder<TImpl> Impl_;
+ };
+
+ using TServiceContextPtr = TIntrusiveConstPtr<TServiceContext>;
+}
diff --git a/library/cpp/tvmauth/deprecated/user_context.cpp b/library/cpp/tvmauth/deprecated/user_context.cpp
new file mode 100644
index 0000000000..712f622f1a
--- /dev/null
+++ b/library/cpp/tvmauth/deprecated/user_context.cpp
@@ -0,0 +1,20 @@
+#include <library/cpp/tvmauth/checked_user_ticket.h>
+#include <library/cpp/tvmauth/src/user_impl.h>
+
+namespace NTvmAuth {
+ static const char* EX_MSG = "UserContext already moved out";
+
+ TUserContext::TUserContext(EBlackboxEnv env, TStringBuf tvmKeysResponse)
+ : Impl_(MakeHolder<TImpl>(env, tvmKeysResponse))
+ {
+ }
+
+ TUserContext::TUserContext(TUserContext&& o) = default;
+ TUserContext& TUserContext::operator=(TUserContext&& o) = default;
+ TUserContext::~TUserContext() = default;
+
+ TCheckedUserTicket TUserContext::Check(TStringBuf ticketBody) const {
+ Y_ENSURE(Impl_, EX_MSG);
+ return Impl_->Check(ticketBody);
+ }
+}
diff --git a/library/cpp/tvmauth/deprecated/user_context.h b/library/cpp/tvmauth/deprecated/user_context.h
new file mode 100644
index 0000000000..f7fe67d02e
--- /dev/null
+++ b/library/cpp/tvmauth/deprecated/user_context.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <library/cpp/tvmauth/checked_user_ticket.h>
+
+#include <util/generic/ptr.h>
+
+namespace NTvmAuth {
+ class TUserContext: public TAtomicRefCount<TUserContext> {
+ public:
+ TUserContext(EBlackboxEnv env, TStringBuf tvmKeysResponse);
+ TUserContext(TUserContext&&);
+ ~TUserContext();
+
+ TUserContext& operator=(TUserContext&&);
+
+ /*!
+ * Parse and validate user ticket body then create TCheckedUserTicket object.
+ * @param ticketBody
+ * @return TCheckedUserTicket object
+ */
+ TCheckedUserTicket Check(TStringBuf ticketBody) const;
+
+ class TImpl;
+
+ private:
+ THolder<TImpl> Impl_;
+ };
+
+ using TUserContextPtr = TIntrusiveConstPtr<TUserContext>;
+}