GoogleCloudPlatform / GoogleCloudPlatform/esp-v2

"Jwt is not in the form of Header.Payload.Signature with two dots and 3 sections" Similar to #342

Open
#944 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
307
Forks
185
Avg merge
14h 45m
Merged PRs (30d)
6

Description

I am running into this issue when enabling token authentication in api gateway. I have a grpc service in cloud run with api gateway configured fronting it. If I configure api gateway with no auth (allow_unregistered_calls=true) and I set the authorization header in the metadata, the call succeeds and I can see the token passed to the backend as x-forwarded-authorization and I can decode that token using jwt.io. The token is an Entra ID id_token.

When I modify the config to include auth:

authentication:
providers:
- id: entra_id
jwks_uri: https://login.microsoftonline.com/common/discovery/v2.0/keys
issuer: https://login.microsoftonline.com/tenanid/v2.0
audiences: clientid
rules:
- selector: '*'
requirements:
- provider_id: entra_id
- usage:
rules:
- selector: "*"
allow_unregistered_calls: false

I get the error in the title of this issue. The token clearly has the 3 segments as decodes fine in jwt.io. It seems this error is only returned when doing the parse so I'm at a loss as to what the issue could be. It would seem that the token being passed to jwt parse is not the correct token. I am making the call with metadata=(("authorization", f"Bearer {jwt}"). As mentioned, I can see this token being passed along as x-forwarded-authorization, so the gateway seems to be picking it up.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the API Gateway authentication configuration with the gRPC authorization metadata and compare the original authorization value with x-forwarded-authorization. Trace where the token is parsed and determine why the valid three-section token is rejected; done means the cause is identified and the behavior is corrected or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, google-cloud, grpc
Domain
api, authentication, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.