* Added an option to remove authentication

* Updated README to document disabling authentication

Co-authored-by: Przemek Dragańczuk <admin@draganczuk.tk>
This commit is contained in:
Przemek Dragańczuk
2020-09-19 10:01:36 +02:00
committed by GitHub
parent 8734ba63d9
commit a26e3fb98f
3 changed files with 26 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ public class App {
after(Filters::addGZIP);
// No need to auth in dev
if (System.getenv("dev") == null) {
if (System.getenv("dev") == null && Utils.isPasswordEnabled()) {
// Authenticate
before("/api/*", Filters.createAuthFilter());
}

View File

@@ -27,4 +27,14 @@ public class Utils {
return PATTERN.matcher(shortUrl)
.matches();
}
public static boolean isPasswordEnabled(){
String disablePasswordEnv = System.getenv("INSECURE_DISABLE_PASSWORD");
if(disablePasswordEnv != null && disablePasswordEnv.equals("I_KNOW_ITS_BAD")){
return false;
}
return true;
}
}