Show basic_auth warning only on startup

This commit is contained in:
Ilja Neumann
2020-11-18 12:48:31 +01:00
parent 37b8f3a303
commit 79e7f85a57
2 changed files with 9 additions and 2 deletions

View File

@@ -15,6 +15,9 @@ const publicFilesEndpoint = "/remote.php/dav/public-files/"
// BasicAuth provides a middleware to check if BasicAuth is provided
func BasicAuth(optionSetters ...Option) func(next http.Handler) http.Handler {
options := newOptions(optionSetters...)
if options.EnableBasicAuth {
options.Logger.Warn().Msg("basic auth enabled, use only for testing or development")
}
return func(next http.Handler) http.Handler {
return &basicAuth{
@@ -41,8 +44,6 @@ func (m basicAuth) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}
m.logger.Warn().Msg("basic auth enabled, use only for testing or development")
login, password, _ := req.BasicAuth()
account, status := getAccount(m.logger, m.accountsClient, fmt.Sprintf("login eq '%s' and password eq '%s'", strings.ReplaceAll(login, "'", "''"), strings.ReplaceAll(password, "'", "''")))