This commit is contained in:
@@ -20,7 +20,7 @@ func recoverMiddleware(next http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
// BasicAuth implements a simple middleware handler for adding basic http auth to a route.
|
||||
func BasicAuth(realm string, creds map[string]string) func(next http.Handler) http.Handler {
|
||||
func (s *HTTPServer) BasicAuth(realm string) func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
user, pass, ok := r.BasicAuth()
|
||||
@@ -29,7 +29,7 @@ func BasicAuth(realm string, creds map[string]string) func(next http.Handler) ht
|
||||
return
|
||||
}
|
||||
|
||||
credPass := creds[user]
|
||||
credPass := s.creds[user]
|
||||
if err := bcrypt.CompareHashAndPassword([]byte(credPass), []byte(pass)); err != nil {
|
||||
basicAuthFailed(w, r, realm)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user