middleware

package
v1.10.19 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(next http.Handler, getter IDTokenGetter) http.Handler

AuthMiddleware is a middleware for authentication by http.Handler.

func Authenticate

func Authenticate(ctx context.Context, idToken string) (*authapi.UserInfo, error)

Authenticate is a function that authenticates the request and returns a UserInfo.

ref: https://docs.saasus.io/reference/getuserinfo

func ExtractReferer added in v1.0.0

func ExtractReferer(next http.Handler) http.Handler

ExtractReferer extracts referer from request and set it to context.

Types

type IDTokenGetter

type IDTokenGetter interface {
	// GetIDToken returns ID token from request.
	//
	// For example, you can get it from query parameters or headers.
	GetIDToken(*http.Request) string
}

IDTokenGetter is an interface for getting ID token from request.

type IdTokenGetterFromAuthHeader added in v1.0.0

type IdTokenGetterFromAuthHeader struct{}

IdTokenGetterFromAuthHeader is an implementation of IDTokenGetter.

func (*IdTokenGetterFromAuthHeader) GetIDToken added in v1.0.0

GetIDToken is a function that returns an IDToken from Authorization header.

Jump to

Keyboard shortcuts

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