authserver

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package authserver implements types related to the communication of authentication via an auth proxy sidecar.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GinHeaderParserMiddleware

func GinHeaderParserMiddleware(ctx *gin.Context)

GinHeaderParserMiddleware is a gin middleware that behaves like the middleware returned from NewHeaderParserMiddleware.

func MustGetContextAuthClaims

func MustGetContextAuthClaims(ctx context.Context) *authn.Claims

MustGetContextAuthClaims is like MustGetContextAuthHeader but returns the claims from Header.

func NewHeaderParserMiddleware deprecated

func NewHeaderParserMiddleware(next http.Handler) http.Handler

NewHeaderParserMiddleware returns a middleware that parses the auth headers into a Header object and adds it to the request context. Use GetContextAuthHeader to retrieve the parsed header from the context.

Deprecated: We generally want to use gin as our web framework. Maintaining both middlewares means more work. Please migrate towards GinHeaderParserMiddleware.

func SetContextAuthHeader

func SetContextAuthHeader(ctx context.Context, header *Header) context.Context

Types

type AuthServer

type AuthServer struct {
	// contains filtered or unexported fields
}

AuthServer is a http.Handler that validates authentication information on http.Request objects.

Trusted requests are responded with a status 204 and additional headers containing decoded information about the request user, etc.

Untrusted requests are responded with a status 401.

func NewAuthServer

func NewAuthServer(stack *authn.AuthStack) *AuthServer

func (*AuthServer) ServeHTTP

func (server *AuthServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)
type Header struct {
	Claims *authn.Claims
}

Header are the headers set by an AuthServer after a request has successfully been authenticated.

func GetContextAuthHeader

func GetContextAuthHeader(ctx context.Context) *Header

GetContextAuthHeader tries to get a Header object from the given context.

Returns nil if no value is found.

func MustGetContextAuthHeader

func MustGetContextAuthHeader(ctx context.Context) *Header

MustGetContextAuthHeader is like GetContextAuthHeader but panics if no value is found.

func NewHeader

func NewHeader(claims *authn.Claims) *Header

func ParseHeader

func ParseHeader(from http.Header) (*Header, error)

ParseHeader takes a http.Header and tries to parse Header from it. Use this function if you receive requests that are being authenticated by an AuthServer.

This will return an error if any non-optional header are missing.

When parsing, Header.Claims will not be validated but only parsed.

func (*Header) SetOn

func (h *Header) SetOn(header http.Header)

Jump to

Keyboard shortcuts

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