auth

package
v0.0.0-...-38dac57 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SigningKey      = []byte("123")
	ErrTokenExpired = errors.New("token is expired")
	ErrTokenIllegal = errors.New("token is illegal")
)
View Source
var ErrorNoAuth = errors.New("no auth")
View Source
var (
	TokenLimitPerAccount int64 = 10
)

Functions

func JwtWithCreateToken

func JwtWithCreateToken(accountId string, role string, expireIn time.Duration) (string, error)

func StateTokenWithCount

func StateTokenWithCount(ctx context.Context, id string) (int64, error)

TODO:

LUA 改造

func StateTokenWithParseJwtToken

func StateTokenWithParseJwtToken(jwtToken string) (string, error)

func StateTokenWithRenew

func StateTokenWithRenew(ctx context.Context, oldToken, newToken string, id string, expiresIn time.Duration) error

func StateTokenWithRevoke

func StateTokenWithRevoke(ctx context.Context, token string) error

func StateTokenWithRevokeAll

func StateTokenWithRevokeAll(ctx context.Context, id string) error

func StateTokenWithSearchList

func StateTokenWithSearchList(ctx context.Context, id string) ([]string, error)

Types

type JwtClaims

type JwtClaims struct {
	AccountId string `json:"account_id"`
	Role      string `json:"role"`
	jwt.RegisteredClaims
}

func JwtWithParseToken

func JwtWithParseToken(tokenStr string, f func(string) error) (*JwtClaims, error)

Jump to

Keyboard shortcuts

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