auth

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 9 Imported by: 10

Documentation

Index

Constants

View Source
const (
	ActionLogin          = rbac.ActionLogin
	ActionSignUp         = rbac.ActionSignUp
	ActionResetPassword  = rbac.ActionResetPassword
	ActionChangePassword = rbac.ActionChangePassword
	ActionSendCode       = rbac.ActionSendCode
)

定义几种常用的授权动作

View Source
const (
	MechanismPassword = rbac.MechanismPassword
	MechanismEmail    = rbac.MechanismEmail
	MechanismPhone    = rbac.MechanismPhone
)

定义几种常用的验证机制

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication interface {
	Request

	Account() string
	Secret() []byte
}

Authentication 表示一个身份验证请求

type Authenticator

type Authenticator interface {

	// 验证用户身份
	Authenticate(a Authentication) error
}

Authenticator 表示一个身份验证算法

type Authorization

type Authorization interface {
	Request
}

Authorization 表示一个授权请求

type Authorizer

type Authorizer interface {

	// 向用户授权
	Authorize(a Authorization) error
}

Authorizer 表示一个授权组件

type Mechanism added in v1.0.14

type Mechanism interface {
	Support(r Request) bool
}

Mechanism 表示一个验证/授权机制组件

type PasswordCalculator

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

PasswordCalculator 是默认的密码计算器

func (*PasswordCalculator) Compute

func (inst *PasswordCalculator) Compute(plain []byte) []byte

Compute 计算密码的哈希值

func (*PasswordCalculator) Reset added in v1.0.20

func (inst *PasswordCalculator) Reset() *PasswordCalculator

Reset ...

func (*PasswordCalculator) Verify

func (inst *PasswordCalculator) Verify(plain []byte) error

Verify 验证密码是否正确

func (*PasswordCalculator) WithSalt added in v1.0.20

func (inst *PasswordCalculator) WithSalt(salt []byte) *PasswordCalculator

WithSalt ...

func (*PasswordCalculator) WithTarget added in v1.0.20

func (inst *PasswordCalculator) WithTarget(target []byte) *PasswordCalculator

WithTarget ...

type Registration

type Registration struct {
	Authenticator Authenticator
	Authorizer    Authorizer
	Mechanism     Mechanism
	Priority      int
	Enabled       bool
}

Registration ... 注册信息

type Registry

type Registry interface {
	ListRegistrations() []*Registration
}

Registry ... 注册接口

type Request added in v1.0.14

type Request interface {
	Context() context.Context
	Attributes() attributes.Table
	Parameters() parameters.Table
	Action() string
	Mechanism() string
}

Request 包含 Authentication 和 Authorization 的公共方法

type RequestBuilder added in v1.0.14

type RequestBuilder struct {
	Context   context.Context
	Atts      attributes.Table
	Params    parameters.Table
	Account   string
	Action    string
	Mechanism string
	Secret    lang.Base64
}

RequestBuilder 用于创建 Authentication & Authorization 实例

func (*RequestBuilder) Create added in v1.0.14

func (inst *RequestBuilder) Create() Authentication

Create 创建 Authentication 实例

type Service

type Service interface {
	Handle(r Authentication) error
}

Service ...

Jump to

Keyboard shortcuts

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