Skip to content

Commit 0d9831e

Browse files
authored
Fix sqs json api folder service token to 24 3 (#11640)
1 parent c7e36ae commit 0d9831e

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

ydb/core/http_proxy/http_req.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ namespace NKikimr::NHttpProxy {
462462

463463
public:
464464
void Bootstrap(const TActorContext& ctx) {
465+
PoolId = ctx.SelfID.PoolID();
465466
StartTime = ctx.Now();
466467
try {
467468
HttpContext.RequestBodyToProto(&Request);
@@ -553,15 +554,14 @@ namespace NKikimr::NHttpProxy {
553554
.Counters = nullptr,
554555
.AWSSignature = std::move(HttpContext.GetSignature()),
555556
.IAMToken = HttpContext.IamToken,
556-
.FolderID = HttpContext.FolderId
557+
.FolderID = HttpContext.FolderId,
558+
.RequestFormat = NSQS::TAuthActorData::Json,
559+
.Requester = ctx.SelfID
557560
};
558561

559-
auto authRequestProxy = MakeHolder<NSQS::THttpProxyAuthRequestProxy>(
560-
std::move(data),
561-
"",
562-
ctx.SelfID);
563-
564-
ctx.RegisterWithSameMailbox(authRequestProxy.Release());
562+
AppData(ctx.ActorSystem())->SqsAuthFactory->RegisterAuthActor(
563+
*ctx.ActorSystem(),
564+
std::move(data));
565565
}
566566

567567
ctx.Schedule(RequestTimeout, new TEvents::TEvWakeup());

ydb/core/http_proxy/ut/datastreams_fixture.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <ydb/core/http_proxy/http_service.h>
1818
#include <ydb/core/http_proxy/metrics_actor.h>
1919
#include <ydb/core/mon/sync_http_mon.h>
20+
#include <ydb/core/ymq/actor/auth_multi_factory.h>
2021

2122
#include <ydb/library/aclib/aclib.h>
2223
#include <ydb/library/persqueue/tests/counters.h>
@@ -703,6 +704,11 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
703704
actorId = as->Register(NKikimr::NFolderService::CreateFolderServiceActor(folderServiceConfig, "cloud4"));
704705
as->RegisterLocalService(NSQS::MakeSqsFolderServiceID(), actorId);
705706

707+
NActors::TActorSystemSetup::TLocalServices services {};
708+
MultiAuthFactory = std::make_unique<NKikimr::NSQS::TMultiAuthFactory>();
709+
MultiAuthFactory->Initialize(services, *AppData(as), AppData(as)->SqsConfig);
710+
AppData(as)->SqsAuthFactory = MultiAuthFactory.get();
711+
706712
for (ui32 i = 0; i < ActorRuntime->GetNodeCount(); i++) {
707713
auto nodeId = ActorRuntime->GetNodeId(i);
708714

@@ -742,6 +748,7 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
742748
std::unique_ptr<grpc::Server> AccessServiceServer;
743749
std::unique_ptr<grpc::Server> IamTokenServer;
744750
std::unique_ptr<grpc::Server> DatabaseServiceServer;
751+
std::unique_ptr<NKikimr::NSQS::TMultiAuthFactory> MultiAuthFactory;
745752
TAutoPtr<TMon> Monitoring;
746753
TIntrusivePtr<NMonitoring::TDynamicCounters> Counters = {};
747754
THolder<NYdbGrpc::TGRpcServer> GRpcServer;

ydb/core/ymq/actor/auth_factory.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,29 @@ namespace NKikimr::NSQS {
1313
struct TAuthActorData {
1414
// Used by both private and public API
1515

16+
enum ESqsRequestFormat {
17+
Xml = 0,
18+
Json
19+
};
20+
1621
THolder<NKikimrClient::TSqsRequest> SQSRequest;
1722
THolder<IReplyCallback> HTTPCallback;
1823
std::function<void(TString)> UserSidCallback;
19-
2024
bool EnableQueueLeader;
21-
2225
// Used by private API only
23-
2426
EAction Action;
25-
2627
ui32 ExecutorPoolID;
2728
TStringBuf CloudID;
2829
TStringBuf ResourceID;
29-
3030
TCloudAuthCounters * Counters; //nullptr when constructed from public API
31-
3231
THolder<TAwsRequestSignV4> AWSSignature;
33-
3432
// Used only by private API for which AWSSignature is empty.
3533

3634
TStringBuf IAMToken;
3735
TStringBuf FolderID;
36+
37+
ESqsRequestFormat RequestFormat = Xml;
38+
TActorId Requester;
3839
};
3940

4041
/**

ydb/core/ymq/actor/auth_multi_factory.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,21 @@ void TMultiAuthFactory::RegisterAuthActor(NActors::TActorSystem& system, TAuthAc
583583
}
584584

585585
const ui32 poolID = data.ExecutorPoolID;
586-
system.Register( //token needed only for ResourceManager
587-
new TCloudAuthRequestProxy(std::move(data), UseResourceManagerFolderService_ ? CredentialsProvider_->GetAuthInfo() : ""),
588-
NActors::TMailboxType::HTSwap,
589-
poolID);
586+
587+
// token needed only for ResourceManager
588+
const auto token = UseResourceManagerFolderService_ ? CredentialsProvider_->GetAuthInfo() : "";
589+
590+
if (data.RequestFormat == NSQS::TAuthActorData::Json) {
591+
system.Register(
592+
new THttpProxyAuthRequestProxy(std::move(data), token, data.Requester),
593+
NActors::TMailboxType::HTSwap,
594+
poolID);
595+
} else {
596+
system.Register(
597+
new TCloudAuthRequestProxy(std::move(data), token),
598+
NActors::TMailboxType::HTSwap,
599+
poolID);
600+
}
590601
}
591602

592603
TMultiAuthFactory::TCredentialsFactoryPtr

0 commit comments

Comments
 (0)