jwtcore

package
v0.0.0-...-05b0b22 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jwk

type Jwk struct {
	// RFC 7517 4.1
	Kty string `json:"kty"`

	// RFC 7517 4.2
	Use string `json:"use"`

	// RFC 7517 4.4
	Alg string `json:"alg"`

	// RFC 7517 4.5
	Kid string `json:"kid"`

	// RFC 7517 4.7
	X5c []string `json:"x5c"`

	// RFC 7518 6.2.1
	Crv string `json:"crv"`
	X   string `json:"x"`
	Y   string `json:"y"`

	// RFC 7518 6.3.1
	N string `json:"n"`
	E string `json:"e"`
}

Jwk represents a single key in a JWK Set (RFC 7517). Only common fields for RSA, EC, and X.509 certificate chain keys are modeled.

type Jwks

type Jwks struct {
	Keys []Jwk `json:"keys"`

	// Inline holds any JWK Set members not matched by a typed field above. The
	// ",inline" option makes json v2 treat it as an inline sink, so a single
	// Unmarshal decodes the known fields and collects the rest here. Each member
	// is kept as raw JSON so its value can be decoded on demand into the type the
	// caller expects, without an eager decode to any that would lose number
	// precision.
	Inline map[string]jsontext.Value `json:",inline"`
}

func DecodeJwks

func DecodeJwks(bytes []byte) (*Jwks, error)

type JwksStore

type JwksStore interface {
	GetByKid(issuer string, kid string) (crypto.PublicKey, error)
}

type JwsHeader

type JwsHeader struct {
	// RFC 7515 4.1.1 Algorithm
	Alg string `json:"alg"`

	// RFC 7515 4.1.4 Key ID
	Kid string `json:"kid,omitempty"`

	// RFC 7515 4.1.9 Type
	Typ string `json:"typ"`
}

See RFC 7515 for JWS structure https://datatracker.ietf.org/doc/html/rfc7515

func (*JwsHeader) LookupHashFunction

func (h *JwsHeader) LookupHashFunction() (crypto.Hash, error)

type JwtPayload

type JwtPayload struct {
	// RFC 7519 4.1.1 Issuer
	Iss string `json:"iss,omitempty"`

	// RFC 7519 4.1.2 Subject
	Sub string `json:"sub,omitempty"`

	// RFC 7519 4.1.3 Audience
	Aud StringOrStrings `json:"aud,omitempty"`

	// RFC 7519 4.1.4 Expiration Time
	Exp *int64 `json:"exp,omitempty"`

	// RFC 7519 4.1.5 Not Before
	Nbf *int64 `json:"nbf,omitempty"`

	// RFC 7519 4.1.6 Issued At
	Iat *int64 `json:"iat,omitempty"`

	// RFC 7519 4.1.7 JWT ID
	Jti string `json:"jti,omitempty"`
}

See RFC 7519 for JWT claims structure https://datatracker.ietf.org/doc/html/rfc7519

type StringOrStrings

type StringOrStrings []string

func (StringOrStrings) MarshalJSON

func (s StringOrStrings) MarshalJSON() ([]byte, error)

func (*StringOrStrings) UnmarshalJSON

func (s *StringOrStrings) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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