Specials thanks for Go Fiber JWT GoFiber/JWT
This is for get signature Json Web Key (JWK) RFC 7517 JSON Web Key (JWK) and save signature.
jwt.JwtMiddleware(config ...Config) func(*fiber.Ctx)
Coming soon!
go get -u github.com/juandiii/go-jwk-security/v2
package main
import (
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/juandiii/go-jwk-security/v2/jwt"
"github.com/juandiii/go-jwk-security/v2/security"
)
type Server struct {
JwtKey *security.JwtKeys
}
func main() {
server := &Server{JwtKey: &security.JwtKeys{JwtURL: "https://sso.example.net/realm/protocol/openid-connect/certs"}}
err := server.JwtKey.GetKeys()
if err != nil {
fmt.Println(err)
return
}
app := fiber.New()
app.Use(jwt.JwtMiddleware(jwt.Config{
KeyFunc: server.JwtKey.GetKey,
}))
app.Get("/", func(c *fiber.Ctx) error {
return nil
})
app.Listen(":3000")
}
- Improve or clean code
- Add more functions
- Fetch Certs after 24h expiration