aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrew-rykov <arykov@ydb.tech>2023-05-16 18:16:31 +0300
committerandrew-rykov <arykov@ydb.tech>2023-05-16 18:16:31 +0300
commit70624ba41fab132764eda048605c802302d1599e (patch)
treea6a2e960be36186e4c6fb118f505269f2e63eaf5
parent8895066b064358eca3c4a51010cf7e7e8a10171f (diff)
downloadydb-70624ba41fab132764eda048605c802302d1599e.tar.gz
Revert custom reply CORS headers
This reverts commit b8029018e37925dab6feb4cb7d13b0922367734b, reversing changes made to 36dd59260620e99b340adfe123e4e8a8fe4d887d.
-rw-r--r--ydb/core/mon/async_http_mon.cpp3
-rw-r--r--ydb/core/mon/mon_impl.h28
-rw-r--r--ydb/core/security/login_page.cpp45
3 files changed, 13 insertions, 63 deletions
diff --git a/ydb/core/mon/async_http_mon.cpp b/ydb/core/mon/async_http_mon.cpp
index e98843af320..369140fe998 100644
--- a/ydb/core/mon/async_http_mon.cpp
+++ b/ydb/core/mon/async_http_mon.cpp
@@ -310,8 +310,7 @@ public:
resultPage.Parent = ActorMonPage->Parent;
resultPage.Output(Container);
} else {
- TCustomResult result(*(ev->Get()));
- result.Output(Container);
+ ev->Get()->Output(Container);
}
ReplyWith(Event->Get()->Request->CreateResponseString(Container.Str()));
PassAway();
diff --git a/ydb/core/mon/mon_impl.h b/ydb/core/mon/mon_impl.h
index 01621d28a45..dc54b7c35ff 100644
--- a/ydb/core/mon/mon_impl.h
+++ b/ydb/core/mon/mon_impl.h
@@ -227,34 +227,6 @@ protected:
TString User;
};
-class TCustomResult {
-public:
- TCustomResult(const NMon::IEvHttpInfoRes &result)
- : Result(result)
- {
- }
-
- void Output(NMonitoring::IMonHttpRequest& request) {
- IOutputStream& out = request.Output();
-
- out << "HTTP/1.1 200 Ok\r\n"
- << "Content-Type: text/html\r\n"
- << "Connection: Close\r\n";
- TString origin = TString(request.GetHeader("Origin"));
- if (origin.empty()) {
- origin = "*";
- }
- out << "Access-Control-Allow-Origin: " << origin << "\r\n"
- << "Access-Control-Allow-Credentials: true\r\n"
- << "Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept\r\n"
- << "Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n";
-
- Result.Output(request.Output());
- }
-
-private:
- const NMon::IEvHttpInfoRes &Result;
-};
////////////////////////////////////////////////////////////////////////////////
// HTML results page
diff --git a/ydb/core/security/login_page.cpp b/ydb/core/security/login_page.cpp
index a4f455bbdb3..ad5290e3a66 100644
--- a/ydb/core/security/login_page.cpp
+++ b/ydb/core/security/login_page.cpp
@@ -171,6 +171,14 @@ public:
ReplyErrorAndPassAway("504 Gateway Timeout", "Timeout");
}
+ void ReplyOptionsAndPassAway() {
+ Result.SetValue(MakeHolder<NMon::TEvHttpInfoRes>(
+ "HTTP/1.1 204 No Content\r\n"
+ "Allow: OPTIONS, POST\r\n"
+ "Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
+ PassAway();
+ }
+
TString GetCORS() {
TStringBuilder res;
TString origin = TString(Request.GetHeader("Origin"));
@@ -184,17 +192,6 @@ public:
return res;
}
- void ReplyOptionsAndPassAway() {
- TStringStream response;
- response << "HTTP/1.1 204 No Content\r\n";
- response << "Allow: OPTIONS, POST\r\n";
- response << "Connection: Keep-Alive\r\n";
- response << GetCORS();
- response << "\r\n";
- Result.SetValue(MakeHolder<NMon::TEvHttpInfoRes>(response.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
- PassAway();
- }
-
void ReplyCookieAndPassAway(const TString& cookie) {
TStringStream response;
TDuration maxAge = (ToInstant(NLogin::TLoginProvider::GetTokenExpiresAt(cookie)) - TInstant::Now());
@@ -336,27 +333,11 @@ public:
ReplyErrorAndPassAway("504 Gateway Timeout", "Timeout");
}
- TString GetCORS() {
- TStringBuilder res;
- TString origin = TString(Request.GetHeader("Origin"));
- if (origin.empty()) {
- origin = "*";
- }
- res << "Access-Control-Allow-Origin: " << origin << "\r\n";
- res << "Access-Control-Allow-Credentials: true\r\n";
- res << "Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept\r\n";
- res << "Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n";
- return res;
- }
-
void ReplyOptionsAndPassAway() {
- TStringStream response;
- response << "HTTP/1.1 204 No Content\r\n";
- response << "Allow: OPTIONS, POST\r\n";
- response << "Connection: Keep-Alive\r\n";
- response << GetCORS();
- response << "\r\n";
- Result.SetValue(MakeHolder<NMon::TEvHttpInfoRes>(response.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
+ Result.SetValue(MakeHolder<NMon::TEvHttpInfoRes>(
+ "HTTP/1.1 204 No Content\r\n"
+ "Allow: OPTIONS, POST\r\n"
+ "Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
PassAway();
}
@@ -364,7 +345,6 @@ public:
TStringStream response;
response << "HTTP/1.1 200 OK\r\n";
response << "Set-Cookie: ydb_session_id=; Max-Age=0\r\n";
- response << GetCORS();
response << "\r\n";
Result.SetValue(MakeHolder<NMon::TEvHttpInfoRes>(response.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
PassAway();
@@ -378,7 +358,6 @@ public:
response << "HTTP/1.1 " << status << "\r\n";
response << "Content-Type: application/json\r\n";
response << "Content-Length: " << responseBody.Size() << "\r\n";
- response << GetCORS();
response << "\r\n";
response << responseBody;
Result.SetValue(MakeHolder<NMon::TEvHttpInfoRes>(response.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));