fix(admin): accept OAuth callback query strings
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m42s
Foundation / postgres-tools (push) Successful in 1m43s
Foundation / server-image (push) Successful in 5m17s
Foundation / image (push) Successful in 6m2s

This commit is contained in:
aevolution-gitops-bot
2026-10-27 13:37:30 -04:00
parent d851717b7b
commit 4adcc7b638
3 changed files with 10 additions and 4 deletions
+6 -1
View File
@@ -147,6 +147,11 @@ void OpsServer::respond_api(Connection& c, const ApiHandler& handler) {
}
const auto method = line.substr(0, first);
const auto path = line.substr(first + 1, second - first - 1);
// The route is bounded separately from the query. OAuth authorization-code callbacks
// carry state, session_state, and code parameters that legitimately make the request
// target longer than the route limit; AdminApi strips the query before routing.
const auto query = path.find('?');
const auto route = path.substr(0, query);
std::string_view authorization;
bool has_body = false;
// Header lines up to the blank line; names are case-insensitive.
@@ -173,7 +178,7 @@ void OpsServer::respond_api(Connection& c, const ApiHandler& handler) {
}
if (method != "GET" && method != "POST")
response = {405, "method not allowed\n"};
else if (path.empty() || path.front() != '/' || path.size() > 256 || !printable(path) ||
else if (route.empty() || route.front() != '/' || route.size() > 256 || !printable(path) ||
has_body)
response = {400, "bad request\n"};
else