diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java index e5abfb328a..5bd3904e47 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java @@ -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/ or https://git:@git.overleaf.com/")); + } } /*