Merge pull request #886 from owncloud/show-basic-auth-warning-on-startup-only

Show basic_auth warning only on startup
This commit is contained in:
Phil Davis
2020-11-18 19:25:33 +05:45
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
Enhancement: Show basic-auth warning only once
Show basic-auth warning only on startup instead on every request.
https://github.com/owncloud/ocis/pull/886

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, "'", "''")))