JWT: Support for x509 PEM cert
See original GitHub issueHello! Thanks for the nice work!
To provide a bit of backgorund , I am trying to use firebase authentication on cf workers environment.
So I was trying to use this package until I find out, firebase-auth doesn’t provide JWKS.json
instead they provide "public keys in (pem) format , to verify signature. Here are the keys for reference, https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com
Is there a plan to support verifying JWT with public keys in this package? If you can give some hint on how to generate jwk from public keys, or if you think there is another way to do it, I would be happy to create a PR for the feature.
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to get a JSON Web Key (JWK) from a PEM-encoded X ...
509 certificate or keys. Developers working with JOSE and JWT may occasionally may need to create a public JWK or a public /...
Read more >Problem validating JWT with X509 cert/pubkey from /jwks
I am trying to implement my server side JWT access token validation (in java) into my API code using a restful service filter....
Read more >Generating X.509 certificates of BTP managed services
1) Generating a service key with certificate credentials We typically use the client id and client secret to generate the JWT token from...
Read more >Protecting REST Endpoints with JWTs: End-to-end Guide
The example below demonstrates how X.509 SSL Certificates can be used to sign and verify JWT tokens without having to use a pre-shared ......
Read more >decode ruby/jwt using pem certificate - Stack Overflow
Assuming pem contains the pem encoded string cert = OpenSSL::X509::Certificate.new(pem) key = cert.public_key decoded_token = JWT.decode ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jdanyow We were able to convert x509 certificate to
CryptoKey
following that blog post, but at the end it turns out firebase publishes JWKs with standard format here , though they don’t mention it in the docs. So we decided to use that.As you can see firebase don’t publish the keys in the standard
/.well-known/jwks.json
path.I will make a PR to cover such cases. I think adding optional keyset parameter will make it flexible.
The keys you linked appear to be PEM encoded x509 certs. I found a blog post that describes how to parse these and eventually use importKey to get a CryptoKey. Assuming all that works you could then export the CryptoKey as a jwk that
@cfworker/jwt
can use.Example:
Then you can pass the jwk to
@cfworker/jwt
’simportKey
function (below).issuer
should match theiss
value found in the JWTs you’re trying to validate. https://github.com/cfworker/cfworker/blob/2292f528ac85397f538256447d8e00e840c4cdeb/packages/jwt/src/jwks.ts#L20-L25Hope that helps!