middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

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

func AuthzMiddleware

func AuthzMiddleware(options AuthzOptions) func(http.Handler) http.Handler

func FindAuthToken

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

func GetAuthTokenFromContext

func GetAuthTokenFromContext(ctx context.Context) string

func GetUserFromContext

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

func ParseAuthTokenHeader

func ParseAuthTokenHeader(headers http.Header) string

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 AuthzOptions

type AuthzOptions struct {
	Context core.Context
	Casbin  *casbin.Enforcer
	Role    string
}

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