auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminUsername        = "system:admin"
	AnonymousUsername    = "system:anonymous"
	StreamUsernamePrefix = "system:stream:"
	NormalUsernamePrefix = "user:"
)

Variables

This section is empty.

Functions

func IsAdmin

func IsAdmin(username string) bool

IsAdmin 返回用户是否管理员

func IsAnonymous

func IsAnonymous(username string) bool

IsAnonymous 返回用户是否未认证用户

func IsOwner

func IsOwner(username string, meta *metav1.ObjectMeta) bool

IsOwner 返回用户是否是指定对象所有者

func IsStream

func IsStream(username string, streamName string) bool

IsStream 返回用户是否指定流

func IsStreams

func IsStreams(username string) bool

IsStreams 返回用户是否是流

func RandNormalUsername

func RandNormalUsername() string

RandNormalUsername 生成一个随机用户名

func StreamUsername

func StreamUsername(streamName string) string

StreamUsername 返回指定流用户名

Types

type TokenAuthenticator

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

TokenAuthenticator 基于 Token 的认证器

func NewTokenAuthenticator

func NewTokenAuthenticator(opts TokenAuthenticatorOptions) *TokenAuthenticator

NewTokenAuthenticator 创建 TokenAuthenticator

func (*TokenAuthenticator) AuthenticateToken

func (a *TokenAuthenticator) AuthenticateToken(token string) (username string, err error)

AuthenticateToken 认证 Token

func (*TokenAuthenticator) IssueToken

func (a *TokenAuthenticator) IssueToken(username string, expire time.Duration) (token string, err error)

IssueToken 签发 Token

type TokenAuthenticatorOptions

type TokenAuthenticatorOptions struct {
	Issuer  string
	SignKey []byte
}

TokenAuthenticatorOptions TokenAuthenticator 选项

func (*TokenAuthenticatorOptions) Complete

func (opts *TokenAuthenticatorOptions) Complete()

Complete 补全选项

Jump to

Keyboard shortcuts

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