casbin

package
v0.0.0-...-96f2668 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelContextKey        contextKey = "CasbinModel"
	PolicyContextKey       contextKey = "CasbinPolicy"
	EnforcerContextKey     contextKey = "CasbinEnforcer"
	SecurityUserContextKey contextKey = "CasbinSecurityUser"
)

Variables

View Source
var (
	ErrSecurityUserCreatorMissing = errors.Forbidden(reason, "SecurityUserCreator is required")
	ErrEnforcerMissing            = errors.Forbidden(reason, "Enforcer is missing")
	ErrSecurityParseFailed        = errors.Forbidden(reason, "Security Info fault")
	ErrUnauthorized               = errors.Forbidden(reason, "Unauthorized Access")
)

Functions

func Client

func Client(opts ...Option) middleware.Middleware

func SecurityUserFromContext

func SecurityUserFromContext(ctx context.Context) (authn.SecurityUser, bool)

SecurityUserFromContext extract SecurityUser from context

func Server

func Server(opts ...Option) middleware.Middleware

Types

type Option

type Option func(*options)

func WithAutoLoadPolicy

func WithAutoLoadPolicy(auto bool, per time.Duration) Option

WithAutoLoadPolicy enable policy auto load option

func WithCasbinEnforcer

func WithCasbinEnforcer(enforcer stdcasbin.IEnforcer) Option

func WithCasbinModel

func WithCasbinModel(model model.Model) Option

func WithCasbinPolicy

func WithCasbinPolicy(policy persist.Adapter) Option

func WithDomainSupport

func WithDomainSupport() Option

WithDomainSupport enable domain support

func WithSecurityUserCreator

func WithSecurityUserCreator(securityUserCreator authn.SecurityUserCreator) Option

func WithWatcher

func WithWatcher(watcher persist.Watcher) Option

WithWatcher Set Watcher for Casbin

Jump to

Keyboard shortcuts

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