jwt

package
v0.4.22 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 17 Imported by: 16 modules, 24 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const JWKSPath = ".well-known/jwks.json"

Variables

This section is empty.

Functions

func GenerateJwksJSON added in v0.4.4

func GenerateJwksJSON(publicKey *ecdsa.PublicKey) ([]byte, error)

func GenerateKeyPair added in v0.4.4

func GenerateKeyPair() (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)

func GenerateToken

func GenerateToken(username string, privateKey *ecdsa.PrivateKey, id int, issuer string, t time.Duration) (string, error)

func GetAccessToken

func GetAccessToken(username string, privateKey *ecdsa.PrivateKey, id int) (string, error)

get AccessToken

func GetRefreshToken

func GetRefreshToken(username string, private *ecdsa.PrivateKey, id int) (string, error)

func JWKSHandler added in v0.4.4

func JWKSHandler(jwksJSON []byte) http.Handler

func JWT

func JWT(publicKeyFunc func() (*ecdsa.PublicKey, error)) echo.MiddlewareFunc

func PublicKeyFromJwksJSON added in v0.4.4

func PublicKeyFromJwksJSON(jwksJSON []byte) (*ecdsa.PublicKey, error)

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	ID       int    `json:"id"`
	jwt.RegisteredClaims
}

func ParseToken

func ParseToken(signedToken string, publicKeyFunc func() (*ecdsa.PublicKey, error)) (*Claims, error)

func Validate

func Validate(token string, publicKeyFunc func() (*ecdsa.PublicKey, error)) (bool, *Claims, error)

type JWK added in v0.4.4

type JWK struct {
	Kty string `json:"kty"`
	Crv string `json:"crv"`
	X   string `json:"x"`
	Y   string `json:"y"`
}

type JWKS added in v0.4.4

type JWKS struct {
	Keys []JWK `json:"keys"`
}

Jump to

Keyboard shortcuts

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