juandiii / go-jwk-security

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About


Languages

Language:Go 100.0%