Skip to content

juandiii/go-jwk-security

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. Improve or clean code
  2. Add more functions
  3. Fetch Certs after 24h expiration