Skip to content

Commit

Permalink
Return 401 for unauthenticated requests in middleware, not 403
Browse files Browse the repository at this point in the history
  • Loading branch information
someone1 committed May 21, 2019
1 parent 09a1f54 commit f42d40a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Google Cloud KMS [now supports signatures](https://cloud.google.com/kms/docs/cre

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

## Breaking Changes with v2

Expand Down
2 changes: 1 addition & 1 deletion jwtmiddleware/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestHelpers(t *testing.T) {
"MissingToken",
audience,
nil,
http.StatusForbidden,
http.StatusUnauthorized,
},
{
"InvalidAudienceToken",
Expand Down
2 changes: 1 addition & 1 deletion jwtmiddleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewHandler(ctx context.Context, config *gcpjwt.IAMConfig, audience string)

token, err := request.ParseFromRequest(r, request.AuthorizationHeaderExtractor, keyFunc, request.WithClaims(claims))
if err != nil || !token.Valid {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}

Expand Down

0 comments on commit f42d40a

Please sign in to comment.