token

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Zlib Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateClient

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

func GenerateServer

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

func GenerateServerToken

func GenerateServerToken(source app.Source) string

func IsClientAuthenticate

func IsClientAuthenticate(source app.Source) bool

func IsServerAuthenticate

func IsServerAuthenticate(source app.Source) bool

func SetClientAuthenticate

func SetClientAuthenticate(check Check)

func SetServerAuthenticate

func SetServerAuthenticate(check Check)

func UserTokenToServerToken

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

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

Types

type AuthenticateFunc

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

type Check

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

type Key

type Key secret.Key

type Session

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

type Token

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

func AuthenticateWithClient

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

func AuthenticateWithServer

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

func NewToken

func NewToken(key Key) *Token

func UnVerifyToken

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

UnVerifyToken *

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

func VerifyToken

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

VerifyToken *

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

func (*Token) Generate

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

func (*Token) GetApp

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

func (*Token) GetAuthType

func (tk *Token) GetAuthType() string

func (*Token) GetKey

func (tk *Token) GetKey() Key

func (*Token) Update

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

Jump to

Keyboard shortcuts

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