jwt

package
v1.0.0-alpha6 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 3 modules, 2 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 ExceptLocalhost

func ExceptLocalhost(publicKeyFunc func() (*ecdsa.PublicKey, error)) gin.HandlerFunc

func GenerateJwksJSON

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

func GenerateKeyPair

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

func JWKSHandler(jwksJSON []byte) http.Handler

func JWT

func JWT(publicKeyFunc func() (*ecdsa.PublicKey, error)) gin.HandlerFunc

func PublicKeyFromJwksJSON

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

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

type JWKS

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