jwt

package
v0.4.7-alpha2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 15 Imported by: 12

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 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)) gin.HandlerFunc

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