wip 0.0.5
All checks were successful
CloudSave/pipeline/head This commit looks good

This commit is contained in:
2025-09-02 22:32:07 +02:00
parent 8518503d40
commit 0a33d1b68d
15 changed files with 288 additions and 14 deletions

View File

@@ -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