middleware

package
v0.22.5 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: BSD-3-Clause Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControl added in v0.10.4

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

AccessControl middleware to restrict to make POST/PUT/DELETE requests by admin only

func NewAccessControl added in v0.10.4

func NewAccessControl(audience, userIDClaim string, getUser GetUser) *AccessControl

NewAccessControl instance constructor

func (*AccessControl) Handler added in v0.10.4

func (a *AccessControl) Handler(h http.Handler) http.Handler

Handler method of the middleware which forbids all modify requests for non admin users It also adds

type AuthMiddleware added in v0.15.0

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

AuthMiddleware middleware to verify personal access tokens (PAT) and JWT tokens

func NewAuthMiddleware added in v0.15.0

func NewAuthMiddleware(getAccountFromPAT GetAccountFromPATFunc, validateAndParseToken ValidateAndParseTokenFunc, markPATUsed MarkPATUsedFunc, audience string) *AuthMiddleware

NewAuthMiddleware instance constructor

func (*AuthMiddleware) CheckJWTFromRequest added in v0.15.0

func (m *AuthMiddleware) CheckJWTFromRequest(w http.ResponseWriter, r *http.Request) error

CheckJWTFromRequest checks if the JWT is valid

func (*AuthMiddleware) CheckPATFromRequest added in v0.15.0

func (m *AuthMiddleware) CheckPATFromRequest(w http.ResponseWriter, r *http.Request) error

CheckPATFromRequest checks if the PAT is valid

func (*AuthMiddleware) Handler added in v0.15.0

func (m *AuthMiddleware) Handler(h http.Handler) http.Handler

Handler method of the middleware which authenticates a user either by JWT claims or by PAT

type GetAccountFromPATFunc added in v0.15.0

type GetAccountFromPATFunc func(token string) (*server.Account, *server.User, *server.PersonalAccessToken, error)

GetAccountFromPATFunc function

type GetUser added in v0.20.0

type GetUser func(claims jwtclaims.AuthorizationClaims) (*server.User, error)

GetUser function defines a function to fetch user from Account by jwtclaims.AuthorizationClaims

type MarkPATUsedFunc added in v0.15.0

type MarkPATUsedFunc func(token string) error

MarkPATUsedFunc function

type ValidateAndParseTokenFunc added in v0.15.0

type ValidateAndParseTokenFunc func(token string) (*jwt.Token, error)

ValidateAndParseTokenFunc function

Jump to

Keyboard shortcuts

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