oidcauth

package module
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 6 Imported by: 0

README

OIDC-Auth

What is oidc-auth

oidc auth is a go-chi middleware for verification and authentication of a Open ID Connect token. Results are send down the request context.

How does it work

OIDC-Auth utilizes OIDC Discovery,specifically the Well-Known Registry, to gather required information for Verification.

Currently only offline verification is fully implemented. Online verification is still in progress of being implemented Multiple issuers are supported.

Of note: This package is heavily inspired by the jwtauth Middleware and jwx.

Usage

For now the intended user is only me.

How to

Develop

Feel free to fork the project!

Use

Right now oidc-auth is under development and should therefore never be used in a production environment. The package consists of four elements

  • Offline

    • Takes issuerUrl & audience
    • Supplies keyset of the issuer via jwks_uri endpoint of issuer
    • Regularly updates via jwk.Cache
    • Errors according to RFC6750
  • Online (not implemented)

    • Takes issuerUrl,clientId & clientSecret
    • Supplies introspection endpoint of issuer
    • Only Basic Auth supported at the moment.
  • Verifier( Offline | Online) Middleware

    • Go chi compatible middleware
    • Verifies the token from the header, cookie or path query
    • Can also handle multiple issuers with Offline/Online Slices
  • Authenticator Middleware

    • Takes token & verification errors from Verifier
    • Handles reaction to valid & invalid tokens
    • Can be replaced by custom authenticator
Test

Right now there is no testing.

Plans

  • Testing
  • More extensive documentation
  • Online verification

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenCtxKey = &contextKey{"Token"}
	ErrorCtxKey = &contextKey{"Error"}
)

Functions

func Authenticator

func Authenticator(logf func(v ...any)) func(http.Handler) http.Handler

func FromContext

func FromContext(ctx context.Context) (jwt.Token, map[string]interface{}, error)

func NewContext

func NewContext(ctx context.Context, t jwt.Token, err error) context.Context

func Verifier

func Verifier[prop verificationProp](vp prop) func(http.Handler) http.Handler

go-chi middleware

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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