jwt icon indicating copy to clipboard operation
jwt copied to clipboard

Add support for JWK (RFC7517)

Open lggomez opened this issue 3 years ago • 4 comments

Migrated from https://github.com/dgrijalva/jwt-go/issues/249:

dgrijalva commented on Mar 8, 2018

How far down the rabbit hole should we go with this?

See the issue thread for more details

lggomez avatar Aug 03 '21 14:08 lggomez

This is a very large undertaking in the scope of this package IMO (as it has way more responsibilities including performing HTTP requests). Should we decide to implement this, I believe it should be done in a separate package using this one

lggomez avatar Aug 04 '21 18:08 lggomez

I wrote a package for creating a jwt.Keyfunc. It's github.com/MicahParks/keyfunc.

This package does not create a JSON Web Key set (JWKs). It's only used for validating JWTs signed by a JSON Web Keys in the set. It can optionally grab and automatically refresh the JWKs via HTTP with a couple configuration options.

It's currently a separate package that supports a few github.com/dgrijalva/jwt-go forks including this one. Each fork must be explicitly supported as the signature of jwt.Keyfunc contains an argument that is a Go struct, *jwt.Token, not an interface implementation.

type Keyfunc func(*Token) (interface{}, error)

I'd be happy to contribute a modification of my keyfunc package to this repository, if requested. This would not bring the repository to fully supporting JWKs though, as I don't believe it has the ability to create one.

Here's the example from the original issue.

MicahParks avatar Aug 17 '21 19:08 MicahParks

It's useful parse apple sign in token.

greatcat-taihe avatar Nov 09 '21 07:11 greatcat-taihe

It would be interesting to support JWKs ~url~ file as a key in the jwt tool.

AlexanderYastrebov avatar Dec 03 '21 17:12 AlexanderYastrebov