Skip to content

Commit

Permalink
Merge pull request #886 from owncloud/show-basic-auth-warning-on-star…
Browse files Browse the repository at this point in the history
…tup-only

Show basic_auth warning only on startup
  • Loading branch information
phil-davis authored Nov 18, 2020
2 parents bd6b335 + 79e7f85 commit a643ad4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/dont-nag-about-basicauth.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions proxy/pkg/middleware/basic_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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, "'", "''")))
Expand Down

0 comments on commit a643ad4

Please sign in to comment.