* 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:
committed by
GitHub
parent
8734ba63d9
commit
a26e3fb98f
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user