diff options
author | uzhas <uzhas@ydb.tech> | 2023-11-29 13:29:07 +0300 |
---|---|---|
committer | uzhas <uzhas@ydb.tech> | 2023-11-29 15:14:58 +0300 |
commit | c89640502e026fb6c6477c5023480c2ae0d4df69 (patch) | |
tree | 542acda3a2b3e223c6f8406f502a3f079d8eed7d | |
parent | 10247a5dc67d1216fb8033107cc97a5864d3b8c9 (diff) | |
download | ydb-c89640502e026fb6c6477c5023480c2ae0d4df69.tar.gz |
fix bearer usage
-rw-r--r-- | ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp b/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp index 55bd1265e9..086307d3a9 100644 --- a/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp +++ b/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp @@ -33,9 +33,6 @@ #include <ydb/library/ycloud/impl/mock_access_service.h> #include <ydb/library/yql/public/issue/yql_issue_message.h> -#include <util/generic/maybe.h> -#include <util/generic/ptr.h> - #include <library/cpp/lwtrace/mon/mon_lwtrace.h> #include <ydb/library/security/util.h> @@ -46,11 +43,14 @@ #include <ydb/library/folder_service/folder_service.h> #include <ydb/library/folder_service/events.h> -#include <memory> #include <contrib/libs/fmt/include/fmt/format.h> +#include <util/generic/maybe.h> +#include <util/generic/ptr.h> +#include <util/string/ascii.h> #include <util/string/join.h> +#include <util/string/strip.h> namespace NFq { namespace { @@ -110,6 +110,17 @@ public: } }; +TString CutBearer(TString token) { + auto bearer = "Bearer "sv; + if (!AsciiHasPrefixIgnoreCase(token, bearer)) { + return token; + } + // cut prefix and strip + token = token.substr(bearer.size()); + StripInPlace(token); + return token; +} + template<class TEventRequest, class TResponseProxy> class TResolveSubjectTypeActor : public NActors::TActorBootstrapped<TResolveSubjectTypeActor<TEventRequest, TResponseProxy>> { using TBase = NActors::TActorBootstrapped<TResolveSubjectTypeActor<TEventRequest, TResponseProxy>>; @@ -120,15 +131,15 @@ class TResolveSubjectTypeActor : public NActors::TActorBootstrapped<TResolveSubj using TBase::Register; using IRetryPolicy = IRetryPolicy<NCloud::TEvAccessService::TEvAuthenticateResponse::TPtr&>; - ::NFq::TControlPlaneProxyConfig Config; - TActorId Sender; - TRequestCommonCountersPtr Counters; - TString Token; - std::function<void(const TDuration&, bool, bool)> Probe; + const ::NFq::TControlPlaneProxyConfig Config; + const TActorId Sender; + const TRequestCommonCountersPtr Counters; + const TString Token; + const std::function<void(const TDuration&, bool, bool)> Probe; TEventRequest Event; - ui32 Cookie; - TInstant StartTime; - IRetryPolicy::IRetryState::TPtr RetryState; + const ui32 Cookie; + const TInstant StartTime; + const IRetryPolicy::IRetryState::TPtr RetryState; const TActorId AccessService; public: @@ -141,14 +152,15 @@ public: : Config(config) , Sender(sender) , Counters(counters) - , Token(token) + , Token(CutBearer(token)) , Probe(probe) , Event(event) , Cookie(cookie) , StartTime(TInstant::Now()) , RetryState(GetRetryPolicy()->CreateRetryState()) , AccessService(accessService) - {} + { + } static constexpr char ActorName[] = "YQ_CONTROL_PLANE_PROXY_RESOLVE_SUBJECT_TYPE"; |