guard

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNativeRBACGuard

func IsNativeRBACGuard(name string) bool

IsNativeRBACGuard reports whether name is a built-in role or permission guard.

func RunGuards

func RunGuards(ctx Context, names []string, registry Registry) error

RunGuards executes guard IDs in declaration order.

func RunGuardsWithAuth

func RunGuardsWithAuth(ctx Context, names []string, registry Registry, provider auth.Provider) error

RunGuardsWithAuth executes guard IDs in declaration order and resolves native RBAC guard IDs such as role:admin and permission:posts.write through provider.

Types

type Context

type Context struct {
	Context context.Context
	Request *http.Request
	Session map[string]any
}

Context is passed to generated request-time guard functions.

func NewContext

func NewContext(request *http.Request, session map[string]any) Context

NewContext creates the first-slice request context for generated guards.

type Func

type Func func(Context) error

Func authorizes one generated request-time route or endpoint access check.

func NativeRBACGuard

func NativeRBACGuard(name string, provider auth.Provider) Func

NativeRBACGuard returns a guard for a native role or permission guard ID.

type Registry

type Registry map[string]Func

Registry resolves guard IDs to executable guard functions.

Jump to

Keyboard shortcuts

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