utils

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiKey

func ApiKey(expected string) gin.HandlerFunc

ApiKey returns a Gin middleware that enforces the ?key= query parameter.

func ParseRSAPrivateKey

func ParseRSAPrivateKey(pem string) (*rsa.PrivateKey, error)

ParseRSAPrivateKey loads an RSA private key from PEM.

func ParseToken

func ParseToken(tokenString, secret string) (jwt.MapClaims, error)

ParseToken validates a JWT string, defaulting the secret when empty, and returns claims.

func ValidateRS256

func ValidateRS256(tokenString string, pub *rsa.PublicKey, issuer string, audience string) (jwt.MapClaims, error)

ValidateRS256 validates an RS256 JWT using a provided RSA public key.

Types

type JWK

type JWK struct {
	Kty string `json:"kty"`
	Kid string `json:"kid"`
	Use string `json:"use"`
	Alg string `json:"alg"`
	N   string `json:"n"`
	E   string `json:"e"`
}

type JWKS

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

func BuildJWKS

func BuildJWKS(key *rsa.PrivateKey, kid string) (*JWKS, error)

func (*JWKS) Marshal

func (j *JWKS) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

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