middleware

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorUserContextInvalid      = errors.New("user id stored in context is not of type uint")
	ErrorAuthTokenContextInvalid = errors.New("auth token stored in context is not of type string")
)

Functions

func AccessMiddleware added in v0.2.0

func AccessMiddleware(ctx core.Context) func(http.Handler) http.Handler

func AccountVerifiedMiddleware added in v0.2.0

func AccountVerifiedMiddleware(ctx core.Context) func(http.Handler) http.Handler

func AuthMiddleware

func AuthMiddleware(options AuthMiddlewareOptions) func(http.Handler) http.Handler

func CorsMiddleware added in v0.2.0

func CorsMiddleware(opts *cors.Options) func(h http.Handler) http.Handler

func FindAuthToken

func FindAuthToken(r *http.Request, secretKey ed25519.PrivateKey, cookieName string, queryParam string) string

func GetAuthTokenFromContext

func GetAuthTokenFromContext(ctx context.Context) (string, error)

func GetUserFromContext

func GetUserFromContext(ctx context.Context, key ...string) (uint, error)

func ParseAuthTokenHeader

func ParseAuthTokenHeader(headers http.Header) string

func TusCorsMiddleware added in v0.2.0

func TusCorsMiddleware() func(h http.Handler) http.Handler

func TusPathMiddleware added in v0.2.0

func TusPathMiddleware(basePath string) mux.MiddlewareFunc

Types

type AuthMiddlewareOptions

type AuthMiddlewareOptions struct {
	Context        core.Context
	FindToken      FindAuthTokenFunc
	Purpose        core.JWTPurpose
	AuthContextKey string
	EmptyAllowed   bool
	ExpiredAllowed bool
}

type AuthTokenContextKeyType

type AuthTokenContextKeyType string
const AUTH_TOKEN_CONTEXT_KEY AuthTokenContextKeyType = "auth_token"

type FindAuthTokenFunc

type FindAuthTokenFunc func(r *http.Request) string

type UserIdContextKeyType

type UserIdContextKeyType string
const DEFAULT_USER_ID_CONTEXT_KEY UserIdContextKeyType = "user_id"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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