auth

package
v0.0.0-...-dcf75d9 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Compare

func Compare(hashedPassword, password string) error

Compare 比较密文和明文是否相同.

func Encrypt

func Encrypt(source string) (string, error)

Encrypt 使用 bcrypt 加密纯文本.

Types

type Authz

type Authz struct {
	// 使用 Casbin 的同步授权器
	*casbin.SyncedEnforcer
}

Authz 定义了一个授权器,提供授权功能.

func NewAuthz

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

func (*Authz) Authorize

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

type Option

type Option func(*authzConfig)

Option 定义了一个函数选项类型,用于自定义 NewAuthz 的行为.

func DefaultOptions

func DefaultOptions() []Option

DefaultOptions 提供默认的授权器选项配置.

func WithAclModel

func WithAclModel(model string) Option

WithAclModel 允许通过选项自定义 ACL 模型.

func WithAutoLoadPolicyTime

func WithAutoLoadPolicyTime(interval time.Duration) Option

WithAutoLoadPolicyTime 允许通过选项自定义自动加载策略的时间间隔.

Jump to

Keyboard shortcuts

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