From 2efc7f22a705276e7674137fb4a0073a16715c5b Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 20 May 2021 15:24:17 +0100 Subject: [PATCH] Remove old username/password settings These were once used to secure interactions with the web api, back when we allowed anonymous access to git repositories. This feature was dropped in the migration to Overleaf v2, and we use OAuth on those interactions anyway, so these settings are not actually used for anything, and keeping these around is just confusing. --- .../git-bridge/conf/envsubst_template.json | 2 -- services/git-bridge/conf/example_config.json | 2 -- services/git-bridge/conf/local.json | 2 -- .../application/config/Config.java | 18 ------------------ .../wlgitbridge/server/GitBridgeServer.java | 4 ---- .../snapshot/base/SnapshotAPIRequest.java | 19 ------------------- .../WLGitBridgeIntegrationTest.java | 2 -- .../application/config/ConfigTest.java | 12 ------------ .../ac/ic/wlgitbridge/bridge/BridgeTest.java | 2 -- 9 files changed, 63 deletions(-) diff --git a/services/git-bridge/conf/envsubst_template.json b/services/git-bridge/conf/envsubst_template.json index c9c8554025..2e024e2890 100644 --- a/services/git-bridge/conf/envsubst_template.json +++ b/services/git-bridge/conf/envsubst_template.json @@ -2,8 +2,6 @@ "port": ${GIT_BRIDGE_PORT:-8000}, "rootGitDirectory": "${GIT_BRIDGE_ROOT_DIR:-/tmp/wlgb}", "apiBaseUrl": "${GIT_BRIDGE_API_BASE_URL:-https://localhost/api/v0}", - "username": "${GIT_BRIDGE_USERNAME}", - "password": "${GIT_BRIDGE_PASSWORD}", "postbackBaseUrl": "${GIT_BRIDGE_POSTBACK_BASE_URL:-https://localhost}", "serviceName": "${GIT_BRIDGE_SERVICE_NAME:-Overleaf}", "oauth2": { diff --git a/services/git-bridge/conf/example_config.json b/services/git-bridge/conf/example_config.json index 715346e57b..b8901b57ad 100644 --- a/services/git-bridge/conf/example_config.json +++ b/services/git-bridge/conf/example_config.json @@ -2,8 +2,6 @@ "port": 8080, "rootGitDirectory": "/tmp/wlgb", "apiBaseUrl": "https://localhost/api/v0", - "username": "user", - "password": "pass", "postbackBaseUrl": "https://localhost", "serviceName": "Overleaf", "oauth2": { diff --git a/services/git-bridge/conf/local.json b/services/git-bridge/conf/local.json index e4f2fdafa9..0b2e3e1241 100644 --- a/services/git-bridge/conf/local.json +++ b/services/git-bridge/conf/local.json @@ -2,8 +2,6 @@ "port": 8000, "rootGitDirectory": "/tmp/wlgb", "apiBaseUrl": "http://v2.overleaf.test:4000/api/v0", - "username": "user", - "password": "pass", "postbackBaseUrl": "http://git-bridge:8000", "serviceName": "Overleaf", "oauth2": { diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java index a6853e937f..f38804424f 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java @@ -25,8 +25,6 @@ public class Config implements JSONSource { return new Config( config.port, config.rootGitDirectory, - config.username, - "", config.apiBaseURL, config.postbackURL, config.serviceName, @@ -39,8 +37,6 @@ public class Config implements JSONSource { private int port; private String rootGitDirectory; - private String username; - private String password; private String apiBaseURL; private String postbackURL; private String serviceName; @@ -67,8 +63,6 @@ public class Config implements JSONSource { public Config( int port, String rootGitDirectory, - String username, - String password, String apiBaseURL, String postbackURL, String serviceName, @@ -79,8 +73,6 @@ public class Config implements JSONSource { ) { this.port = port; this.rootGitDirectory = rootGitDirectory; - this.username = username; - this.password = password; this.apiBaseURL = apiBaseURL; this.postbackURL = postbackURL; this.serviceName = serviceName; @@ -98,8 +90,6 @@ public class Config implements JSONSource { configObject, "rootGitDirectory" ).getAsString(); - username = getOptionalString(configObject, "username"); - password = getOptionalString(configObject, "password"); String apiBaseURL = getElement( configObject, "apiBaseUrl" @@ -138,14 +128,6 @@ public class Config implements JSONSource { return rootGitDirectory; } - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - public String getAPIBaseURL() { return apiBaseURL; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java index 0b25bf99a7..e97bc57fdf 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java @@ -73,10 +73,6 @@ public class GitBridgeServer { ); jettyServer = new Server(port); configureJettyServer(config, repoStore, snapshotApi); - SnapshotAPIRequest.setBasicAuth( - config.getUsername(), - config.getPassword() - ); apiBaseURL = config.getAPIBaseURL(); SnapshotAPIRequest.setBaseURL(apiBaseURL); Util.setServiceName(config.getServiceName()); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/SnapshotAPIRequest.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/SnapshotAPIRequest.java index d9a77e1df4..583f008cb4 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/SnapshotAPIRequest.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/SnapshotAPIRequest.java @@ -11,9 +11,6 @@ import java.io.IOException; */ public abstract class SnapshotAPIRequest extends Request { - private static String USERNAME; - private static String PASSWORD; - private static String BASE_URL; private final Credential oauth2; @@ -33,27 +30,11 @@ public abstract class SnapshotAPIRequest extends Request { ) throws IOException { if (oauth2 != null) { request.setInterceptor(request1 -> { - new BasicAuthentication( - USERNAME, - PASSWORD - ).intercept(request1); oauth2.intercept(request1); }); - } else { - request.setInterceptor(request1 -> { - new BasicAuthentication( - USERNAME, - PASSWORD - ).intercept(request1); - }); } } - public static void setBasicAuth(String username, String password) { - USERNAME = username; - PASSWORD = password; - } - /* baseURL ends with / */ public static void setBaseURL(String baseURL) { BASE_URL = baseURL + "docs/"; diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java index 31eda92198..50e8ef674e 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java @@ -1069,8 +1069,6 @@ public class WLGitBridgeIntegrationTest { " \"apiBaseUrl\": \"http://127.0.0.1:" + apiPort + "/api/v0\",\n" + - " \"username\": \"\",\n" + - " \"password\": \"\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1:" + port + "\",\n" + diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java index 096efe9609..0a74f67af6 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java @@ -18,8 +18,6 @@ public class ConfigTest { " \"port\": 80,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" + - " \"username\": \"REDACTED\",\n" + - " \"password\": \"REDACTED\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1\",\n" + " \"serviceName\": \"Overleaf\",\n" + " \"oauth2\": {\n" + @@ -32,8 +30,6 @@ public class ConfigTest { assertEquals(80, config.getPort()); assertEquals("/var/wlgb/git", config.getRootGitDirectory()); assertEquals("http://127.0.0.1:60000/api/v0/", config.getAPIBaseURL()); - assertEquals("REDACTED", config.getUsername()); - assertEquals("REDACTED", config.getPassword()); assertEquals("http://127.0.0.1/", config.getPostbackURL()); assertEquals("Overleaf", config.getServiceName()); assertTrue(config.isUsingOauth2()); @@ -48,8 +44,6 @@ public class ConfigTest { " \"port\": 80,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" + - " \"username\": \"REDACTED\",\n" + - " \"password\": \"REDACTED\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1\",\n" + " \"serviceName\": \"Overleaf\",\n" + " \"oauth2\": null\n" + @@ -58,8 +52,6 @@ public class ConfigTest { assertEquals(80, config.getPort()); assertEquals("/var/wlgb/git", config.getRootGitDirectory()); assertEquals("http://127.0.0.1:60000/api/v0/", config.getAPIBaseURL()); - assertEquals("REDACTED", config.getUsername()); - assertEquals("REDACTED", config.getPassword()); assertEquals("http://127.0.0.1/", config.getPostbackURL()); assertEquals("Overleaf", config.getServiceName()); assertFalse(config.isUsingOauth2()); @@ -72,8 +64,6 @@ public class ConfigTest { " \"port\": 80,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" + - " \"username\": \"username\",\n" + - " \"password\": \"my super secret password\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1\",\n" + " \"serviceName\": \"Overleaf\",\n" + " \"oauth2\": {\n" + @@ -86,8 +76,6 @@ public class ConfigTest { String expected = "{\n" + " \"port\": 80,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + - " \"username\": \"username\",\n" + - " \"password\": \"\",\n" + " \"apiBaseURL\": \"http://127.0.0.1:60000/api/v0/\",\n" + " \"postbackURL\": \"http://127.0.0.1/\",\n" + " \"serviceName\": \"Overleaf\",\n" + diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java index 79dc4327b6..edcda98c36 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java @@ -58,8 +58,6 @@ public class BridgeTest { "", "", "", - "", - "", null, null, null,