refactor(ingestion): use strings.CutPrefix for explicit Bearer scheme check
This commit is contained in:
@@ -13,8 +13,8 @@ func BearerAuth(token string, next http.Handler) http.Handler {
|
|||||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
got := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")
|
got, ok := strings.CutPrefix(r.Header.Get("Authorization"), "Bearer ")
|
||||||
if got != token {
|
if !ok || got != token {
|
||||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user