Skip to content

Commit f42d40a

Browse files
committed
Return 401 for unauthenticated requests in middleware, not 403
1 parent 09a1f54 commit f42d40a

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Google Cloud KMS [now supports signatures](https://cloud.google.com/kms/docs/cre
1010

1111
- Dropping support for AppEngine Go 1.9 environment (last version with AppEngine App Identity support will be for Go 1.11)
1212
- KMSConfig no longer takes an optional HTTP Client, but rather the kms gRPC based client
13+
- Middleware will now return a 401 response for unauthenticated requests (previously was returning a 403 response)
1314

1415
## Breaking Changes with v2
1516

jwtmiddleware/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestHelpers(t *testing.T) {
137137
"MissingToken",
138138
audience,
139139
nil,
140-
http.StatusForbidden,
140+
http.StatusUnauthorized,
141141
},
142142
{
143143
"InvalidAudienceToken",

jwtmiddleware/middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewHandler(ctx context.Context, config *gcpjwt.IAMConfig, audience string)
2929

3030
token, err := request.ParseFromRequest(r, request.AuthorizationHeaderExtractor, keyFunc, request.WithClaims(claims))
3131
if err != nil || !token.Valid {
32-
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
32+
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
3333
return
3434
}
3535

0 commit comments

Comments
 (0)