util

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("Token is expired")
	TokenNotValidYet = errors.New("Token not active yet")
	TokenMalformed   = errors.New("That's not even a token")
	TokenInvalid     = errors.New("Couldn't handle this token:")
)

Functions

func BuildPubKey

func BuildPubKey(pubKey string) (*rsa.PublicKey, error)

BuildPubKey 构建公钥

func Contains added in v0.1.2

func Contains[T comparable](slice []T, element T) bool

func DecodeJwt added in v0.1.2

func DecodeJwt(jwt string) (*model.CustomClaims, error)

func DecodePayload added in v0.1.2

func DecodePayload(payload string) (*model.CustomClaims, error)

func GenRsaCertPair

func GenRsaCertPair()

func ReadPriKey deprecated added in v0.0.2

func ReadPriKey(keyPath string) (*rsa.PrivateKey, error)

Deprecated: ReadPriKeyOfAbPath 相对路径

func ReadPriKeyOfAbPath added in v0.1.3

func ReadPriKeyOfAbPath(abPath string) (*rsa.PrivateKey, error)

ReadPriKeyOfAbPath 绝对路径

func ReadPubKey deprecated

func ReadPubKey(keyPath string) (*rsa.PublicKey, error)

Deprecated: ReadPubKeyOfAbPath 读取公钥(相对路径)

func ReadPubKeyOfAbPath added in v0.1.3

func ReadPubKeyOfAbPath(abPath string) (*rsa.PublicKey, error)

ReadPubKeyOfAbPath 读取公钥(绝对路径)

func RemoveBearer added in v0.1.2

func RemoveBearer(token string) string

RemoveBearer remove token Bearer prefix if necessary

Types

type JWTParser

type JWTParser struct {
	SigningKey *rsa.PublicKey
}

func GetParser deprecated

func GetParser(path string) (*JWTParser, error)

Deprecated: GetParserOfAbPath(相对路径)

func GetParserFromKey

func GetParserFromKey(pubKey string) (*JWTParser, error)

func GetParserOfAbPath added in v0.1.4

func GetParserOfAbPath(abPath string) (*JWTParser, error)

func (*JWTParser) ParseToken

func (j *JWTParser) ParseToken(tokenString string) (*model.CustomClaims, error)

ParseToken 解析 token

Jump to

Keyboard shortcuts

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