middleware

package
v7.0.0-...-1c7ecba Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const RequestScopeKey scopeKey = "request-scope"

RequestScopeKey uses a typed string to reduce likelihood of clashing with other context keys

Variables

This section is empty.

Functions

func AddRequestScope

func AddRequestScope(req *http.Request, scope *RequestScope) *http.Request

AddRequestScope adds a RequestScope to a request

Types

type RequestScope

type RequestScope struct {
	// ReverseProxy tracks whether OAuth2-Proxy is operating in reverse proxy
	// mode and if request `X-Forwarded-*` headers should be trusted
	ReverseProxy bool

	// RequestID is set to the request's `X-Request-Id` header if set.
	// Otherwise a random UUID is set.
	RequestID string

	// Session details the authenticated users information (if it exists).
	Session *sessions.SessionState

	// SaveSession indicates whether the session storage should attempt to save
	// the session or not.
	SaveSession bool

	// ClearSession indicates whether the user should be logged out or not.
	ClearSession bool

	// SessionRevalidated indicates whether the session has been revalidated since
	// it was loaded or not.
	SessionRevalidated bool

	// Upstream tracks which upstream was used for this request
	Upstream string
}

RequestScope contains information regarding the request that is being made. The RequestScope is used to pass information between different middlewares within the chain.

func GetRequestScope

func GetRequestScope(req *http.Request) *RequestScope

GetRequestScope returns the current request scope from the given request

type TokenToSessionFunc

type TokenToSessionFunc func(ctx context.Context, token string) (*sessionsapi.SessionState, error)

TokenToSessionFunc takes a raw ID Token and converts it into a SessionState.

func CreateTokenToSessionFunc

func CreateTokenToSessionFunc(verify VerifyFunc) TokenToSessionFunc

CreateTokenToSessionFunc provides a handler that is a default implementation for converting a JWT into a session.

type VerifyFunc

type VerifyFunc func(ctx context.Context, token string) (*oidc.IDToken, error)

VerifyFunc takes a raw bearer token and verifies it returning the converted oidc.IDToken representation of the token.

Jump to

Keyboard shortcuts

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