mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Reject v1 ids earlier in the pipeline
This commit is contained in:
parent
78220d6430
commit
8f72cb89c8
2 changed files with 25 additions and 19 deletions
|
@ -83,23 +83,6 @@ public class WLRepositoryResolver
|
|||
ServiceNotAuthorizedException,
|
||||
ServiceMayNotContinueException {
|
||||
Log.info("[{}] Request to open git repo", name);
|
||||
// Reject v1 ids, the request will be rejected by v1 anyway
|
||||
if (name.matches("^[0-9]+[bcdfghjklmnpqrstvwxyz]{6,12}$") && !name.matches("^[0-9a-f]{24}$")) {
|
||||
Log.info("[{}] Request for v1 project, refusing", name);
|
||||
throw new ServiceMayNotContinueException(
|
||||
String.join("\n", Arrays.asList(
|
||||
"This project has not yet been moved into the new version",
|
||||
"of Overleaf. You will need to move it in order to continue working on it.",
|
||||
"Please visit this project online on www.overleaf.com to do this.",
|
||||
"",
|
||||
"You can find the new git remote url by selecting \"Git\" from",
|
||||
"the left sidebar in the project view.",
|
||||
"",
|
||||
"If this is unexpected, please contact us at support@overleaf.com, or",
|
||||
"see https://www.overleaf.com/help/342 for more information."
|
||||
))
|
||||
);
|
||||
}
|
||||
Optional<Credential> oauth2 = Optional.ofNullable(
|
||||
(Credential) httpServletRequest.getAttribute(
|
||||
Oauth2Filter.ATTRIBUTE_KEY));
|
||||
|
|
|
@ -19,8 +19,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Optional;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by winston on 25/10/15.
|
||||
|
@ -62,6 +61,30 @@ public class Oauth2Filter implements Filter {
|
|||
((Request) servletRequest).getRequestURI().split("/")[1],
|
||||
".git"
|
||||
);
|
||||
// Reject v1 ids, the request will be rejected by v1 anyway
|
||||
if (project.matches("^[0-9]+[bcdfghjklmnpqrstvwxyz]{6,12}$") && !project.matches("^[0-9a-f]{24}$")) {
|
||||
Log.info("[{}] Request for v1 project, refusing", project);
|
||||
HttpServletResponse response = ((HttpServletResponse) servletResponse);
|
||||
response.setContentType("text/plain");
|
||||
response.setStatus(404);
|
||||
PrintWriter w = response.getWriter();
|
||||
List<String> l = Arrays.asList(
|
||||
"This project has not yet been moved into the new version",
|
||||
"of Overleaf. You will need to move it in order to continue working on it.",
|
||||
"Please visit this project online on www.overleaf.com to do this.",
|
||||
"",
|
||||
"You can find the new git remote url by selecting \"Git\" from",
|
||||
"the left sidebar in the project view.",
|
||||
"",
|
||||
"If this is unexpected, please contact us at support@overleaf.com, or",
|
||||
"see https://www.overleaf.com/help/342 for more information."
|
||||
);
|
||||
for (String line : l) {
|
||||
w.println(line);
|
||||
}
|
||||
w.close();
|
||||
return;
|
||||
}
|
||||
Log.info("[{}] Checking if auth needed", project);
|
||||
GetDocRequest doc = new GetDocRequest(project);
|
||||
doc.request();
|
||||
|
|
Loading…
Reference in a new issue