auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExists   = errors.New("the token has already exists")
	ErrTokenNotFound = errors.New("the token was not found")
)

Functions

This section is empty.

Types

type Token

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

func NewToken

func NewToken() *Token

func (*Token) Marshal

func (token *Token) Marshal() ([]byte, error)

Marshal would marshal the token into JSON format

func (*Token) Unmarshal

func (token *Token) Unmarshal(bytes []byte) error

Unmarshal would unmarshal the token from JSON format

type TokenManager

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

func NewTokenManager

func NewTokenManager(zkCli *zk_wrapper.Conn, logger *logrus.Logger) (*TokenManager, error)

NewTokenManager create the token manger and it would sync the tokens from zk

func (*TokenManager) CreateToken

func (tm *TokenManager) CreateToken(token, role string, topics, groups []string) error

CreateTokenh create the new token

func (*TokenManager) DeleteToken

func (tm *TokenManager) DeleteToken(token string) error

func (*TokenManager) GetToken

func (tm *TokenManager) GetToken(token string, sync bool) *Token

GetToken return token in token manager

func (*TokenManager) IsAllowConsume

func (tm *TokenManager) IsAllowConsume(token, group string) bool

IsAllowProduce check whether the token has the permission to consume message or not

func (*TokenManager) IsAllowProduce

func (tm *TokenManager) IsAllowProduce(token, topic string) bool

IsAllowProduce check whether the token has the permission to send message or not

func (*TokenManager) IsTokenExists

func (tm *TokenManager) IsTokenExists(token string) bool

IsTokenExists check the token was exists or not

func (*TokenManager) ListToken

func (tm *TokenManager) ListToken(sync bool) []string

ListToken return token list in token manager

func (*TokenManager) UpdateToken

func (tm *TokenManager) UpdateToken(token string, isAdd bool, role string, topics, groups []string) error

UpdateToken update the token role or topics/groups

Jump to

Keyboard shortcuts

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