go-oidc-middleware

module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2021 License: MIT

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
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL