modulepackage
0.0.0-20220717095707-cd6c39cff7d0
Repository: https://github.com/v4lproik/gin-jwks-rsa.git
Documentation: pkg.go.dev
# README
gin-jwks-rsa

This gin-gonic handler aims at providing a JKMS exposing the public key properties needed in the JWT encryption/decryption workflow using RSA.
Usage
Import your own private key
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()
}
Generate a private key
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()
}
Output
{
"keys": [
{
"kty": "RSA",
"alg": "RS256",
"e": "AQAB",
"n": "6DGyBMjYcC5nf7eHHCqvwdgjr5_6_AnMbV124jtszu62vnMHHSIkVP6e5FWEQRUWXYww2cu-PKV2cJ1PcSvIs-OTwSayJnrQThsK5PzEAsH8pEhAoC2Izlpv4oK7vJYoUulcWTLFq0TcC0GkIZ3rUUn2RRAq508A0FI-ep17PjU7yamZAHwlfZPQ6NEFOnabBUE-qCaquv1PmNXV-PLZhhwAxkuxcGiZCaflkNmH8mw7L79zQWVAVgyIS68OV7CnblbuNwCOOzuLmnEJD3pwCfMq7a22vW_HXfVWzRqehkfgvH2Dmakbfm17WzFaWo_a8AUaU8ojY8DK-YxV0pU0ow",
"use": "sig",
"kid": "my-id"
}
]
}
# Packages
No description provided by the author
# Functions
EncodeToString utility which converts []byte into a base64 string.
Jkws middleware exposing the public key properties required in order to decrypt a jwt token.
Initialise a new config builder.
# Constants
No description provided by the author
# Structs
Config represents the available options for the middleware.
Config builder.
Import key face of the config builder.
New key facet of the config builder.
Structure used when the user imports an existing private key.
Refer to rfc for more information: https://www.rfc-editor.org/rfc/rfc7518#section-6.3.1.
Structure used when the user generates a new private key.
# Interfaces
No description provided by the author