jwt

package
v0.4.4-alpha3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

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