auth

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Zlib Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateClient added in v0.2.6

func GenerateClient(session Session, app app.Info, auth string, expire int32) (string, error)

func GenerateServer added in v0.2.6

func GenerateServer(session Session, app app.Info, auth string, expire int32) (string, error)

func GenerateServerToken added in v0.2.6

func GenerateServerToken(source app.Source) string

func IsClientAuthenticate added in v0.2.6

func IsClientAuthenticate(source app.Source) bool

func IsServerAuthenticate added in v0.2.6

func IsServerAuthenticate(source app.Source) bool

func SetClientAuthenticate added in v0.2.6

func SetClientAuthenticate(auth Check)

func SetServerAuthenticate added in v0.2.6

func SetServerAuthenticate(auth Check)

func SourceAt

func SourceAt(source string) string

func SourceKeyForClient

func SourceKeyForClient(source app.Source) string

func SourceKeyForServer

func SourceKeyForServer(source app.Source) string

func UserTokenToServerToken added in v0.2.6

func UserTokenToServerToken(userToken, source string) (string, error)

UserTokenToServerToken 从用户端到服务器,服务器到服务器之间需要的认证

Types

type Authenticate

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

func New

func New(mgr SecretMgr) *Authenticate

func (*Authenticate) Check

func (t *Authenticate) Check(source app.Source, token string) (*Token, error)

Check implement server.Authenticate interface

func (*Authenticate) Generate

func (t *Authenticate) Generate(session Session, app app.Info, auth string, expire int32) (string, error)

Generate implement server.Authenticate interface

func (*Authenticate) IsEnabled

func (t *Authenticate) IsEnabled(source app.Source) bool

IsEnabled implement server.Authenticate interface

func (*Authenticate) SetEnabled

func (t *Authenticate) SetEnabled(source app.Source, enable bool)

SetEnabled implement server.Authenticate interface

type AuthenticateFunc added in v0.2.6

type AuthenticateFunc func(source app.Source, token string) (*Token, error)

type Check added in v0.2.6

type Check interface {
	Generate(session Session, app app.Info, auth string, expire int32) (string, error)
	IsEnabled(source app.Source) bool
	SetEnabled(source app.Source, enable bool)
	Check(source app.Source, token string) (*Token, error)
}

type Item

type Item struct {
	Enabled bool          `json:"enabled"`
	Secret  server.Secret `json:"secret"`
}

type Mgr

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

func NewMgr

func NewMgr(skFuncs SourceKeyFuncs) *Mgr

func (*Mgr) AddItem

func (mgr *Mgr) AddItem(source app.Source, item Item)

func (*Mgr) AddItemWithKey

func (mgr *Mgr) AddItemWithKey(key string, item Item)

func (*Mgr) AddSecret

func (mgr *Mgr) AddSecret(source app.Source, secret server.Secret)

func (*Mgr) AddSecretWithKey

func (mgr *Mgr) AddSecretWithKey(key string, secret server.Secret)

func (*Mgr) GetSecret

func (mgr *Mgr) GetSecret(source app.Source) server.Secret

func (*Mgr) IsEnabled

func (mgr *Mgr) IsEnabled(source app.Source) bool

IsEnabled implement server.Authenticate interface

func (*Mgr) Load

func (mgr *Mgr) Load(file string) error

func (*Mgr) SetEnabled

func (mgr *Mgr) SetEnabled(source app.Source, enable bool)

SetEnabled implement server.Authenticate interface

type SecretMgr

type SecretMgr interface {
	GetSecret(source app.Source) server.Secret
	SetEnabled(source app.Source, enable bool)
	IsEnabled(source app.Source) bool
}

type Session added in v0.2.6

type Session struct {
	Uid     string `json:"uid"`
	Session string `json:"-"`
}

type SourceKeyFuncs

type SourceKeyFuncs func(source app.Source) string

SourceKeyFuncs source to key function

type Token added in v0.2.6

type Token struct {
	Session
	Token string `json:"token"`
	// contains filtered or unexported fields
}

func AuthenticateWithClient added in v0.2.6

func AuthenticateWithClient(source app.Source, token string) (*Token, error)

func AuthenticateWithServer added in v0.2.6

func AuthenticateWithServer(source app.Source, token string) (*Token, error)

func NewToken added in v0.2.6

func NewToken(key TokenKey) *Token

func UnVerifyToken added in v0.2.6

func UnVerifyToken(tk string) (*Token, error)

UnVerifyToken *

  • 不需要认证,解包里面的信息

func VerifyToken added in v0.2.6

func VerifyToken(tk string, key TokenKey) (*Token, error)

VerifyToken *

  • 需要认证,解包里面的信息

func (*Token) Generate added in v0.2.6

func (tk *Token) Generate(session Session, app app.Info, auth string) (string, error)

func (*Token) GetApp added in v0.2.6

func (tk *Token) GetApp() app.Info

func (*Token) GetAuthType added in v0.2.6

func (tk *Token) GetAuthType() string

func (*Token) GetKey added in v0.2.6

func (tk *Token) GetKey() TokenKey

func (*Token) Update added in v0.2.6

func (tk *Token) Update() (string, error)

type TokenKey added in v0.2.6

type TokenKey interface {
	Key() []byte
	ExpireIn() int32
}

Jump to

Keyboard shortcuts

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