authz

package
v0.0.0-...-9912f9e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package authz provides authorization functionality using Casbin for access control with RBAC (Role-Based Access Control) model and GORM database integration.

Index

Constants

This section is empty.

Variables

ProviderSet is a Wire Provider set used to declare dependency injection rules. Contains the NewAuthz constructor for generating Authz instances.

Functions

This section is empty.

Types

type Authz

type Authz struct {
	*casbin.SyncedEnforcer // Uses Casbin's synchronized enforcer
}

Authz defines an authorizer that provides authorization functionality.

func NewAuthz

func NewAuthz(db *gorm.DB, opts ...Option) (*Authz, error)

NewAuthz creates an authorizer using Casbin for authorization, supporting custom configuration through functional options pattern.

func (*Authz) Authorize

func (a *Authz) Authorize(sub, obj, act string) (bool, error)

Authorize performs authorization checks.

type Option

type Option func(*authzConfig)

Option defines a function option type for customizing NewAuthz behavior.

func DefaultOptions

func DefaultOptions() []Option

DefaultOptions provides default authorizer option configuration.

func WithAclModel

func WithAclModel(model string) Option

WithAclModel allows customizing the ACL model through options.

func WithAutoLoadPolicyTime

func WithAutoLoadPolicyTime(interval time.Duration) Option

WithAutoLoadPolicyTime allows customizing the automatic policy loading time interval through options.

Jump to

Keyboard shortcuts

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