Skip to content

Commit cda9439

Browse files
committed
don't return an error from the middleware
1 parent 3a764d2 commit cda9439

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

auth/auth_middleware.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,10 @@ func (ah *AuthHandler) AuthMiddleware(next http.Handler) http.Handler {
4040
headerParts := strings.SplitN(header, " ", 2)
4141
if len(headerParts) == 2 && strings.EqualFold(headerParts[0], "Bearer") {
4242
token = headerParts[1]
43-
} else {
44-
/* only send an error if the header exists but is wrong,
45-
if it doesn't exist, they're not logged in, which is fine, no err */
46-
http.Error(w, "Authorization header exists, but it's invalid", 400)
47-
return
4843
}
4944
}
5045
}
51-
/* this AuthMiddleware should only send an error if the structure of the req
52-
is broken. stuff like invalid/expired tokens should NOT cause an error response
46+
/* stuff like invalid/expired tokens should NOT cause an error response
5347
because this middleware should only populate authedUser context stuff
5448
each handler controls any error responses if not logged in based on auth context,
5549
because some handlers allow not-logged-in users while others might not */

0 commit comments

Comments
 (0)