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