refactor(ingestion): use strings.CutPrefix for explicit Bearer scheme check

This commit is contained in:
Mathias Bergqvist
2026-05-07 21:02:14 +02:00
parent 228ee57d4c
commit c509ae2a5f

View File

@@ -13,8 +13,8 @@ func BearerAuth(token string, next http.Handler) http.Handler {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
got := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")
if got != token {
got, ok := strings.CutPrefix(r.Header.Get("Authorization"), "Bearer ")
if !ok || got != token {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}