auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSON = &jsonProvider{}

JSON json 提供者

Functions

func Del

func Del(userName string) error

Del 删除指定名称的用户

func Flush

func Flush() error

Flush 刷新用户

func Reset

func Reset(provider UserProvider)

Reset 重置用户提供者

func Save

func Save(src *User, updatePassword bool) error

Save 保存用户

Types

type AccessRight

type AccessRight int

AccessRight 访问权限类型

const (
	PullRight AccessRight = 1 << iota // 拉流权限
	PushRight                         // 推流权限
)

权限常量

type Mode

type Mode int

Mode 认证模式

const (
	NoneAuth Mode = iota
	BasicAuth
	DigestAuth
)

认证模式常量

func (*Mode) Get

func (m *Mode) Get() interface{}

Get flag.Getter 接口实现

func (Mode) MarshalText

func (m Mode) MarshalText() ([]byte, error)

MarshalText 编入认证模式到文本

func (*Mode) Set

func (m *Mode) Set(s string) error

Set flag.Value 接口实现.

func (Mode) String

func (m Mode) String() string

String 返回认证模式字串

func (*Mode) UnmarshalText

func (m *Mode) UnmarshalText(text []byte) error

UnmarshalText 从文本编出认证模式 典型的用于 YAML、TOML、JSON等文件编出

type PathMatcher

type PathMatcher interface {
	Match(path string) bool
}

PathMatcher 路径匹配接口

func NewPathMatcher

func NewPathMatcher(pathMask string) PathMatcher

NewPathMatcher 创建匹配器

type Token

type Token struct {
	Username string `json:"-"`
	AToken   string `json:"access_token"`
	AExp     int64  `json:"-"`
	RToken   string `json:"refresh_token"`
	RExp     int64  `json:"-"`
}

Token 用户登录后的Token

type TokenManager

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

TokenManager token管理

func (*TokenManager) AccessCheck

func (tm *TokenManager) AccessCheck(atoken string) string

AccessCheck 访问检测

func (*TokenManager) ExpCheck

func (tm *TokenManager) ExpCheck()

ExpCheck 过期检测

func (*TokenManager) NewToken

func (tm *TokenManager) NewToken(username string) *Token

NewToken 给用户新建Token

func (*TokenManager) Refresh

func (tm *TokenManager) Refresh(rtoken string) *Token

Refresh 刷新指定的Token

type User

type User struct {
	Name       string `json:"name"`
	Password   string `json:"password,omitempty"`
	Admin      bool   `json:"admin,omitempty"`
	PushAccess string `json:"push,omitempty"`
	PullAccess string `json:"pull,omitempty"`
	// contains filtered or unexported fields
}

User 用户

func All

func All() []*User

All 获取所有的用户

func Get

func Get(userName string) *User

Get 获取取指定名称的用户

func (*User) CopyFrom

func (u *User) CopyFrom(src *User, withPassword bool)

CopyFrom 从源属性并初始化

func (*User) PasswordMD5

func (u *User) PasswordMD5() string

PasswordMD5 返回口令的MD5字串

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) error

ValidatePassword 验证密码

func (*User) ValidatePermission

func (u *User) ValidatePermission(path string, right AccessRight) bool

ValidatePermission 验证权限

type UserProvider

type UserProvider interface {
	LoadAll() ([]*User, error)
	Flush(full []*User, saves []*User, removes []*User) error
}

UserProvider 用户提供者

Jump to

Keyboard shortcuts

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