A middleware for validating JWT tokens made by an OpenID Connect compliant provider
By fetching information from the discovery URL (.well-known) it can validate a JWT token sent with an Authentication header.
NewAuthenticationMiddleware(discoveryURL url.URL) *jwtmiddleware.JWTMiddleware
NewGinAuthenticationMiddleware(discoveryURL url.URL) *gin.HandlerFunc
import github.com/oslokommune/go-oidc-middleware/pkg/v1/middleware"
func NewRouter() *gin.Engine {
router := gin.Default()
discoveryURL, err := url.Parse("https://auth-provider.url/.well-known/openid-configuration")
if err != nil {
panic(err)
}
router.Use(middleware.NewGinAuthenticationMiddleware(*discoveryURL))
return router
}