middleware

package
v0.0.0-...-c78e9a6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: LGPL-2.1 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureBearerToken

func CaptureBearerToken(secretKey string) echo.MiddlewareFunc

CaptureBearerToken captures and parses JWT token, sets user info to context

func DefaultScopeRefExtractor

func DefaultScopeRefExtractor(c echo.Context) string

func GetDeviceIdFromContext

func GetDeviceIdFromContext(ctx context.Context) string

func GetRolesFromContext

func GetRolesFromContext(ctx context.Context) []string

func GetUserIdFromContext

func GetUserIdFromContext(ctx context.Context) string

func JwtFromContext

func JwtFromContext(ctx context.Context) string

func RequireAuthMiddleware

func RequireAuthMiddleware() echo.MiddlewareFunc

func RequirePermission

func RequirePermission(
	checker PermissionChecker,
	resource string,
	action string,
	scopeRefFrom ScopeRefExtractor,
) echo.MiddlewareFunc

Must run after RequireAuthMiddleware and RequestContextMiddleware (userId is assumed present).

Types

type CqrsPermissionChecker

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

func NewCqrsPermissionChecker

func NewCqrsPermissionChecker(cqrsBus cqrs.CqrsBus) *CqrsPermissionChecker

func (*CqrsPermissionChecker) CheckPermission

func (c *CqrsPermissionChecker) CheckPermission(
	ctx context.Context,
	subjectRef,
	resourceName,
	actionName,
	scopeRef string,
) (bool, error)

type PermissionChecker

type PermissionChecker interface {
	CheckPermission(ctx context.Context, subjectRef, resourceName, actionName, scopeRef string) (allow bool, err error)
}

type ScopeRefExtractor

type ScopeRefExtractor func(c echo.Context) string

Jump to

Keyboard shortcuts

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