tokenHelper

package
v0.0.0-...-7538a8c Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPrivateFileRSA = "./configs/resources/private_key.pem"
	DefaultPublicFileRSA  = "./configs/resources/public_key.pub"
	DefaultKeyIdentifier  = "236c88d15b514cd3b73bd6b4c1fbe177"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenRequest

type AccessTokenRequest struct {
	GrandType   grandTypeEnums.GrandType
	Id          string
	TokenId     string
	Audience    []string
	CurrentTime time.Time
	ExpiredAt   time.Time
	ClientId    string
	Authorities []string
	Username    string
	Roles       []string
}

type Config

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

func InitConfig

func InitConfig(privateKeyLoc, publicKeyLoc, keyIdentifier string) Config

func (Config) GenerateAccessToken

func (c Config) GenerateAccessToken(req AccessTokenRequest) (string, error)

func (Config) GenerateJWKS

func (c Config) GenerateJWKS() PublicKeysData

func (Config) GenerateRefreshToken

func (c Config) GenerateRefreshToken(req RefreshTokenRequest) (string, error)

func (Config) ParseAccessToken

func (c Config) ParseAccessToken(tokenString string) (*accessToken, error)

func (Config) ParseAccessTokenByJWK

func (c Config) ParseAccessTokenByJWK(tokenString string, publicKeysData PublicKeysData) (*accessToken, error)

func (Config) ParseRefreshToken

func (c Config) ParseRefreshToken(tokenString string) (*refreshToken, error)

func (Config) ParseToken

func (c Config) ParseToken(tokenString string) (*token, error)

type ConfigAuthorize

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

func InitConfigAuthorize

func InitConfigAuthorize(jwkUrl, cacheKey string, redisClient redis.Redis, logger logger.Logger) ConfigAuthorize

func (ConfigAuthorize) FetchCacheableJWK

func (c ConfigAuthorize) FetchCacheableJWK() (*PublicKeysData, error)

func (ConfigAuthorize) FetchJWK

func (c ConfigAuthorize) FetchJWK() (*PublicKeysData, error)

type PublicKeysData

type PublicKeysData struct {
	Keys []keyData `json:"keys"`
}

func (PublicKeysData) ToRaw

func (p PublicKeysData) ToRaw() []byte

type RefreshTokenRequest

type RefreshTokenRequest struct {
	Id          string
	TokenId     string
	Audience    []string
	CurrentTime time.Time
	ExpiredAt   time.Time
}

Jump to

Keyboard shortcuts

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