Skip to content

Commit 3fac1ad

Browse files
authored
[app] Fix token auth (#442)
We used the "strings.TrimLeft" method in the token auth handler, which is not what we want. Instead we should use "strings.TrimPrefix".
1 parent c6edeb6 commit 3fac1ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/satellite/middleware/tokenauth/tokenauth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func Handler(token string) func(next http.Handler) http.Handler {
1414
fn := func(w http.ResponseWriter, r *http.Request) {
1515
if token != "" {
1616
authHeader := r.Header.Get("Authorization")
17-
if !strings.HasPrefix(authHeader, "Bearer ") || strings.TrimLeft(authHeader, "Bearer ") != token {
17+
if !strings.HasPrefix(authHeader, "Bearer ") || strings.TrimPrefix(authHeader, "Bearer ") != token {
1818
errresponse.Render(w, r, fmt.Errorf("authorization token is missing or invalid"), http.StatusUnauthorized, "You are not authorized to access the resource")
1919
return
2020
}

0 commit comments

Comments
 (0)