Merge pull request #99 from overleaf/sk-remove-basic-auth-config

Remove basic auth configuration
This commit is contained in:
Shane Kilkelly 2021-05-25 09:35:10 +01:00 committed by GitHub
commit a544b6e434
9 changed files with 1 additions and 64 deletions

View file

@ -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": {

View file

@ -2,8 +2,6 @@
"port": 8080,
"rootGitDirectory": "/tmp/wlgb",
"apiBaseUrl": "https://localhost/api/v0",
"username": "user",
"password": "pass",
"postbackBaseUrl": "https://localhost",
"serviceName": "Overleaf",
"oauth2": {

View file

@ -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": {

View file

@ -25,8 +25,6 @@ public class Config implements JSONSource {
return new Config(
config.port,
config.rootGitDirectory,
config.username,
"<password>",
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;
}

View file

@ -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());

View file

@ -11,9 +11,6 @@ import java.io.IOException;
*/
public abstract class SnapshotAPIRequest<T extends Result> extends Request<T> {
private static String USERNAME;
private static String PASSWORD;
private static String BASE_URL;
private final Credential oauth2;
@ -30,30 +27,14 @@ public abstract class SnapshotAPIRequest<T extends Result> extends Request<T> {
@Override
protected void onBeforeRequest(
HttpRequest 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/";

View file

@ -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" +

View file

@ -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\": \"<password>\",\n" +
" \"apiBaseURL\": \"http://127.0.0.1:60000/api/v0/\",\n" +
" \"postbackURL\": \"http://127.0.0.1/\",\n" +
" \"serviceName\": \"Overleaf\",\n" +

View file

@ -58,8 +58,6 @@ public class BridgeTest {
"",
"",
"",
"",
"",
null,
null,
null,