Go Fiber - JWK for Auth
๐ It's unofficial middleware for Go Fiber
Specials thanks for Go Fiber JWT GoFiber/JWT
๐ฆ What's in the box?
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)
๐ API
Coming soon!
๐ฝ Get Dependencies
go get -u github.com/juandiii/go-jwk-security/v2
๐จ๐ปโ๐ป Example
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")
}
โ
TODO:
- Improve or clean code
- Add more functions
- Fetch Certs after 24h expiration