Merge pull request #20996 from overleaf/ls-proper-error-for-wrong-git-url-format

proper error message for wrong git url format

GitOrigin-RevId: a6278850c2eca7e85c2526135d1c769fcbe94729
This commit is contained in:
Liangjun Song 2024-10-11 19:42:02 +08:00 committed by Copybot
parent e00831761a
commit 51b46f3909

View file

@ -122,7 +122,7 @@ public class Oauth2Filter implements Filter {
cred.setAccessToken(password);
} else if (this.isUserPasswordEnabled) {
// password auth has been deprecated for git-bridge
handlePasswordAuthenticationDeprecation(projectId, request, response);
handlePasswordAuthenticationDeprecation(projectId, username, request, response);
return;
} else {
handleNeedAuthorization(projectId, username, request, response);
@ -265,14 +265,24 @@ public class Oauth2Filter implements Filter {
}
private void handlePasswordAuthenticationDeprecation(
String projectId, HttpServletRequest request, HttpServletResponse response)
String projectId, String username, HttpServletRequest request, HttpServletResponse response)
throws IOException {
Log.info("[{}] Password authentication deprecated, ip={}", projectId, getClientIp(request));
sendResponse(
response,
403,
Arrays.asList(
"Overleaf now only supports Git authentication tokens to access git. See: https://www.overleaf.com/learn/how-to/Git_integration_authentication_tokens"));
if (username.contains("@")) {
Log.info("[{}] Password authentication deprecated, ip={}", projectId, getClientIp(request));
sendResponse(
response,
403,
Arrays.asList(
"Overleaf now only supports Git authentication tokens to access git. See: https://www.overleaf.com/learn/how-to/Git_integration_authentication_tokens"));
} else {
Log.info("[{}] Wrong git URL format, ip={}", projectId, getClientIp(request));
sendResponse(
response,
403,
Arrays.asList(
"Overleaf now only supports Git authentication tokens to access git. See: https://www.overleaf.com/learn/how-to/Git_integration_authentication_tokens",
"Please make sure your Git URL is correctly formatted. For example: https://git@git.overleaf.com/<YOUR_PROJECT_ID> or https://git:<AUTHENTICATION_TOKEN>@git.overleaf.com/<YOUR_PROJECT_ID>"));
}
}
/*