Allow login during readonly

Login should not be blocked when Gerrit is in read-only mode.

Change-Id: I3a0a2d8d1393b44e5b7e6210c0ded6c3cab31621
diff --git a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
index 3e2d585..f84101c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
@@ -37,6 +37,8 @@
 @Singleton
 class ReadOnly extends AllRequestFilter implements CommitValidationListener {
   private static final String GIT_UPLOAD_PACK_PROTOCOL = "/git-upload-pack";
+  private static final String LOGIN_PREFIX = "/login";
+  private static final String LOGIN_INFIX = LOGIN_PREFIX + "/";
 
   private final ReadOnlyState state;
   private final ReadOnlyConfig config;
@@ -75,7 +77,10 @@
     String method = request.getMethod();
     String servletPath = request.getServletPath();
     return !servletPath.endsWith(endpoint)
-        && (("POST".equals(method) && !servletPath.endsWith(GIT_UPLOAD_PACK_PROTOCOL))
+        && (("POST".equals(method)
+                && !servletPath.endsWith(GIT_UPLOAD_PACK_PROTOCOL)
+                && !servletPath.equals(LOGIN_PREFIX)
+                && !servletPath.contains(LOGIN_INFIX))
             || "PUT".equals(method)
             || "DELETE".equals(method));
   }