auth

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication interface {
	Context() context.Context
	Mechanism() string
	Account() string
	Secret() []byte
}

Authentication 表示一个身份验证请求

type Authenticator

type Authenticator interface {

	// 验证用户身份
	Authenticate(a Authentication) (*Result, error)

	Support(a Authentication) bool
}

Authenticator 表示一个身份验证算法

type Authenticators

type Authenticators interface {

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

Authenticators 表示一组身份验证算法

type Authorization

type Authorization interface {
	Context() context.Context
	User() User
}

Authorization 表示一个授权请求

func NewAuthorization

func NewAuthorization(c context.Context, user User) Authorization

NewAuthorization 新建一个 Authorization 的实例

type Authorizer

type Authorizer interface {
	Authorize(a Authorization) error
	Support(a Authorization) bool
}

Authorizer 表示一个授权组件

type Authorizers

type Authorizers interface {
	Authorize(a Authorization) error
}

Authorizers 表示一组授权组件

type PasswordCalculator

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

PasswordCalculator 是默认的密码计算器

func (*PasswordCalculator) Compute

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

Compute 计算密码的哈希值

func (*PasswordCalculator) Init

func (inst *PasswordCalculator) Init(target, salt []byte)

Init ...

func (*PasswordCalculator) Verify

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

Verify 验证密码是否正确

type Registration

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

Registration ... 注册信息

type Registry

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

Registry ... 注册接口

type Result added in v1.0.8

type Result struct {
	User      User
	Success   bool
	Challenge bool
}

Result 验证结果

type Service

type Service interface {
	Authenticators
	Authorizers

	Login(c context.Context, a Authentication) (*Result, error)
}

Service ...

type User

type User interface {
	ID() rbac.UserID          // 用户ID
	Name() rbac.UserName      // 用户名
	Avatar() string           // 头像图片的 URL
	Roles() rbac.RoleNameList // 角色
	DisplayName() string      // 显示名称(昵称)
}

User 表示经过验证的用户

type UserBuilder

type UserBuilder struct {
	ID          rbac.UserID
	Name        rbac.UserName
	Roles       rbac.RoleNameList
	Avatar      string
	DisplayName string
}

UserBuilder 用于创建 User 实例

func (*UserBuilder) Create

func (inst *UserBuilder) Create() User

Create 。。。

Jump to

Keyboard shortcuts

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