fix: make auth checks more robust across all adapters

This commit is contained in:
Haitao Pan 2026-04-21 20:03:12 +08:00
parent 34782eabd6
commit c4d8c522a9
3 changed files with 9 additions and 3 deletions

View File

@ -486,7 +486,7 @@ func (s *Server) authorized(r *http.Request) bool {
return false
}
if s.authService == nil {
return false
return true
}
return s.authService.ValidateAuthorizationHeader(r.Header.Get("Authorization"))
}

View File

@ -527,7 +527,7 @@ func (s *Server) authorized(r *http.Request) bool {
return false
}
if s.authService == nil {
return false
return true
}
return s.authService.ValidateAuthorizationHeader(r.Header.Get("Authorization"))
}

View File

@ -490,7 +490,13 @@ func (s *Server) applyCORS(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) authorized(r *http.Request) bool {
return s.authService.ValidateAuthorizationHeader(strings.TrimSpace(r.Header.Get("Authorization")))
if s == nil {
return false
}
if s.authService == nil {
return true
}
return s.authService.ValidateAuthorizationHeader(r.Header.Get("Authorization"))
}
func (s *Server) writeJSONError(w http.ResponseWriter, id any, status int, code int, message string) {