feat(auth): add optional HTTP Basic Auth access gate

This commit is contained in:
ji ruo committed 2026-10-09 10:12:27 +08:00
1 parent 979e1fe4eb
commit 04c8c54ff8
14 files changed
+809 -23

No files matched your search

+2 -2
View File
@@ -116,11 +116,11 @@ func extractToken(r *http.Request) string {
}
// requireAuth wraps h with JWT validation.
// /api/auth/* and /api/health are exempt.
// /api/auth/*, /api/health and the Basic Auth gate check are exempt.
func (s *Server) requireAuth(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
p := r.URL.Path
if strings.HasPrefix(p, "/api/auth/") || p == "/api/health" {
if strings.HasPrefix(p, "/api/auth/") || p == "/api/health" || p == "/api/basic-auth/check" {
h.ServeHTTP(w, r)
return
}