Categorygithub.com/oslokommune/go-oidc-middleware
repository
0.0.4
Repository: https://github.com/oslokommune/go-oidc-middleware.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

go-oidc-middleware

A middleware for validating JWT tokens made by an OpenID Connect compliant provider

How it works

By fetching information from the discovery URL (.well-known) it can validate a JWT token sent with an Authentication header.

Middlewares

General

Relevant middleware function

  • NewAuthenticationMiddleware(discoveryURL url.URL) *jwtmiddleware.JWTMiddleware

Gin

Relevant middleware function

  • NewGinAuthenticationMiddleware(discoveryURL url.URL) *gin.HandlerFunc

Usage

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
}