Skip to content

Commit

Permalink
Add missing CORS (#12877)
Browse files Browse the repository at this point in the history
  • Loading branch information
StekPerepolnen authored Dec 27, 2024
1 parent 3250bfc commit c0db9a4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions ydb/mvp/oidc_proxy/oidc_protected_page_nebius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void THandlerSessionServiceCheckNebius::HandleExchange(NHttp::TEvHttpProxy::TEvH
if (!event->Get()->Response) {
BLOG_D("Getting access token: Bad Request");
NHttp::THeadersBuilder responseHeaders;
SetCORS(Request, &responseHeaders);
responseHeaders.Set("Content-Type", "text/plain");
return ReplyAndPassAway(Request->CreateResponse("400", "Bad Request", responseHeaders, event->Get()->Error));
}
Expand Down
2 changes: 2 additions & 0 deletions ydb/mvp/oidc_proxy/oidc_session_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void THandlerSessionCreate::Handle(NHttp::TEvHttpProxy::TEvHttpIncomingResponse:
errorMessage = "Wrong OIDC response";
}
NHttp::THeadersBuilder responseHeaders;
SetCORS(Request, &responseHeaders);
responseHeaders.Set("Content-Type", "text/plain");
return ReplyAndPassAway(Request->CreateResponse("400", "Bad Request", responseHeaders, errorMessage));
} else {
Expand All @@ -87,6 +88,7 @@ void THandlerSessionCreate::Handle(NHttp::TEvHttpProxy::TEvHttpIncomingResponse:
}
} else {
NHttp::THeadersBuilder responseHeaders;
SetCORS(Request, &responseHeaders);
responseHeaders.Set("Content-Type", "text/plain");
return ReplyAndPassAway(Request->CreateResponse("400", "Bad Request", responseHeaders, event->Get()->Error));
}
Expand Down
1 change: 1 addition & 0 deletions ydb/mvp/oidc_proxy/oidc_session_create_nebius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void THandlerSessionCreateNebius::ProcessSessionToken(const TString& sessionToke
BLOG_D("Set session cookie: (" << sessionCookieName << ": " << NKikimr::MaskTicket(sessionCookieValue) << ")");

NHttp::THeadersBuilder responseHeaders;
SetCORS(Request, &responseHeaders);
responseHeaders.Set("Set-Cookie", CreateSecureCookie(sessionCookieName, sessionCookieValue));
responseHeaders.Set("Location", Context.GetRequestedAddress());
ReplyAndPassAway(Request->CreateResponse("302", "Cookie set", responseHeaders));
Expand Down
1 change: 1 addition & 0 deletions ydb/mvp/oidc_proxy/openid_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ NHttp::THttpOutgoingResponsePtr GetHttpOutgoingResponsePtr(const NHttp::THttpInc
<< request->Host
<< GetAuthCallbackUrl();
NHttp::THeadersBuilder responseHeaders;
SetCORS(request, &responseHeaders);
responseHeaders.Set("Set-Cookie", context.CreateYdbOidcCookie(settings.ClientSecret));
if (context.IsAjaxRequest()) {
return CreateResponseForAjaxRequest(request, responseHeaders, redirectUrl);
Expand Down

0 comments on commit c0db9a4

Please sign in to comment.