This gin-gonic handler aims at providing a JKMS exposing the public key properties needed in the JWT encryption/decryption workflow using RSA.
func main() {
r := gin.Default()
builder := NewConfigBuilder()
config, err := builder.
ImportPrivateKey().
WithPath("../testdata/private.pem").
WithKeyId("my-id").
Build()
if err != nil {
fmt.Errorf("error generating conf %v", err)
return
}
r.GET("/.well-known/jwks.json", Jkws(*config))
r.Run()
}
func main() {
r := gin.Default()
builder := NewConfigBuilder()
config, err := builder.
NewPrivateKey().
WithKeyId("my-id").
WithKeyLength(2048).
Build()
if err != nil {
fmt.Errorf("error generating conf %v", err)
return
}
r.GET("/.well-known/jwks.json", Jkws(*config))
r.Run()
}
{
"keys": [
{
"kty": "RSA",
"alg": "RS256",
"e": "AQAB",
"n": "6DGyBMjYcC5nf7eHHCqvwdgjr5_6_AnMbV124jtszu62vnMHHSIkVP6e5FWEQRUWXYww2cu-PKV2cJ1PcSvIs-OTwSayJnrQThsK5PzEAsH8pEhAoC2Izlpv4oK7vJYoUulcWTLFq0TcC0GkIZ3rUUn2RRAq508A0FI-ep17PjU7yamZAHwlfZPQ6NEFOnabBUE-qCaquv1PmNXV-PLZhhwAxkuxcGiZCaflkNmH8mw7L79zQWVAVgyIS68OV7CnblbuNwCOOzuLmnEJD3pwCfMq7a22vW_HXfVWzRqehkfgvH2Dmakbfm17WzFaWo_a8AUaU8ojY8DK-YxV0pU0ow",
"use": "sig",
"kid": "my-id"
}
]
}