The API call does not seem to have “kid” attribute in it, and i also dont see any API’s that can be used to set this attribute while token generation. I have opened a support ticket with Firebase team on this to validate and confirm.
I feel your pain. If the JWT does not include a kid in the header, then perhaps the intent by the Firebase system is that verification will not use JWKS. I haven’t read the docs thoroughly and I don’t know exactly how you’re generating the JWT. But it’s possible there is a different suggested path for verifying. Maybe there is a well-known public key that is not identified by kid, somewhere. In that case you can just refer to the public key directly, without using the kid as a lookup parameter.
this is also “rotatable” public key.
Yes, I can infer that from the format of the payload. It’s a series of key-value pairs where the key is the unique kid, and the value is the certificate in PEM form. Obviously the goal is to support multiple distinct and possibly rotating keys.
In Apigee is there a way to reference public key url to validate the JWT token instead of going through jwks–> kid-- > public key path presuming “kid” will not be part JWT header.
I don’t know how this would work. That URL you gave offers 3 distinct certificates. How would the VerifyJWT policy in Apigee Edge choose one of those certificates to use for verification? The way it works with JWKS is: the kid is the discriminator. If the JWT stipulates kid = X, then VerifyJWT finds the JWK with the kid = X, and uses THAT public key to verify the JWT. And by the way this is not particular to Apigee Edge; this is how JWKS and JWT verificaiton is intended to work. That’s the whole point of the kid in the JWT standard: to identify the public key to be used to verify the signature.
You’re asking “Can Apigee Edge verify a JWT, in the case in which there’s no way to determine which public key to use?” and the answer to that should be obvious. No.
I can imagine you building some logic to iterate through the available public keys, but that seems like a really really bad idea. There needs to be a documented way for verifiers to verify the JWT. Either the JWT has a kid in the header, or there is some alternative, like a documented “Well known” public key that does not rotate.
EDIT. I just read the Firebase documentation regarding custom tokens and here’s what I found. Regarding “custom tokens”:
Custom tokens are signed JWTs where the private key used for signing belongs to a Google service account.
…
This method of initialization is suitable for a wide range of Admin SDK deployments. Also it enables the Admin SDK to create and sign custom tokens locally, without making any remote API calls. The main drawback of this approach is that it requires you to package a service account JSON file [ and hence the private key] along with your code.
Also I found doc on verifying tokens, which says:
The ID token verification methods included in the Firebase Admin SDKs are meant to verify ID tokens that come from the client SDKs, not the custom tokens that you create with the Admin SDKs.
This tells me that when you try to use https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com , you are not using a documented, supported mechanism for verifying custom firebase tokens.
Also, this tells me: The custom token is signed by the private key which is stored in the JSON file. Always. To verify such a token You need to extract the public key from that private key and embed that public key into VerifyJWT, or otherwise make the public key available to the VerifyJWT policy.
There is no kid because the private key is not rotatable. There is just one key - THE private key in the JSON file. It would be good for Firebase to generate a kid anyway, to clarify matters.
But in any case now you know where to find the public key.