Documentation
¶
Overview ¶
Package jwx contains tools that deal with the various JWx (JOSE) technologies such as JWT, JWS, JWE, etc in Go.
JWS (https://tools.ietf.org/html/rfc7515) JWE (https://tools.ietf.org/html/rfc7516) JWK (https://tools.ietf.org/html/rfc7517) JWA (https://tools.ietf.org/html/rfc7518) JWT (https://tools.ietf.org/html/rfc7519)
Examples are stored in a separate Go module (to avoid adding dependencies to this module), and thus does not appear in the online documentation for this module. You can find the examples in Github at https://github.com/lestrrat-go/jwx/tree/v3/examples
You can find more high level documentation at Github (https://github.com/lestrrat-go/jwx/tree/v2)
FAQ style documentation can be found in the repository (https://github.com/lestrrat-go/jwx/tree/develop/v3/docs)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecoderSettings ¶
func DecoderSettings(options ...JSONOption)
DecoderSettings gives you a access to configure the "encoding/json".Decoder used to decode JSON objects within the jwx framework.
All options accepted here have process-global effect and are intended to be applied exactly once at program startup, before any goroutine begins parsing JWx payloads. See the godoc on individual JSONOption constructors (e.g. WithUseNumber) for the concurrency contract of each setting.
Types ¶
type FormatKind ¶
type FormatKind int
const ( // InvalidFormat is returned when the format of the incoming buffer // has been deemed conclusively invalid InvalidFormat FormatKind = iota // UnknownFormat is returned when GuessFormat was not able to conclusively // determine the format of the UnknownFormat JWE JWS JWK JWKS JWT )
These constants describe the result from guessing the format of the incoming buffer.
func GuessFormat ¶
func GuessFormat(payload []byte) FormatKind
GuessFormat is used to guess the format the given payload is in using heuristics. See the type FormatKind for a full list of possible types.
This may be useful in determining your next action when you may encounter a payload that could either be a JWE, JWS, or a plain JWT.
Because JWTs are almost always JWS signed, you may be thrown off if you pass what you think is a JWT payload to this function. If the function is in the "Compact" format, it means it's a JWS signed message, and its payload is the JWT. Therefore this function will return JWS, not JWT.
This function requires an extra parsing of the payload, and therefore may be inefficient if you call it every time before parsing.
func (FormatKind) String ¶
func (i FormatKind) String() string
type JSONOption ¶
type JSONOption interface {
Option
// contains filtered or unexported methods
}
func WithUseNumber ¶
func WithUseNumber(b bool) JSONOption
WithUseNumber controls whether the jwx package should unmarshal JSON objects with the "encoding/json".Decoder.UseNumber feature on.
This setting has process-global effect and must be applied once at program startup (typically from func init() or early in main()) before any goroutine begins parsing JWx payloads. The underlying flag is read atomically, so toggling it at runtime is race-free, but any in-flight or subsequent decoders will observe a mix of float64 and json.Number values in concurrently-decoded custom fields — callers that type-assert on those values will break non-deterministically. There is no per-call override.
Default is false.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
ecutil
Package ecutil defines tools that help with elliptic curve related computation
|
Package ecutil defines tools that help with elliptic curve related computation |
|
Package jwa defines the various algorithm described in https://tools.ietf.org/html/rfc7518
|
Package jwa defines the various algorithm described in https://tools.ietf.org/html/rfc7518 |
|
Package jwe implements JWE as described in https://tools.ietf.org/html/rfc7516.
|
Package jwe implements JWE as described in https://tools.ietf.org/html/rfc7516. |
|
jwebb
Package jwebb provides the building blocks (hence the name "bb") for JWE operations.
|
Package jwebb provides the building blocks (hence the name "bb") for JWE operations. |
|
Package jwk implements JWK as described in https://tools.ietf.org/html/rfc7517
|
Package jwk implements JWK as described in https://tools.ietf.org/html/rfc7517 |
|
internal/registry
Package registry provides an internal registry of JWK key constructors.
|
Package registry provides an internal registry of JWK key constructors. |
|
jwkunsafe
Package jwkunsafe provides low-level JWK key construction functions.
|
Package jwkunsafe provides low-level JWK key construction functions. |
|
Package jws implements the digital signature on JSON based data structures as described in https://tools.ietf.org/html/rfc7515
|
Package jws implements the digital signature on JSON based data structures as described in https://tools.ietf.org/html/rfc7515 |
|
jwsbb
Package jwsbb provides the building blocks (hence the name "bb") for JWS operations.
|
Package jwsbb provides the building blocks (hence the name "bb") for JWS operations. |
|
legacy
Package legacy provides support for legacy implementation of JWS signing and verification.
|
Package legacy provides support for legacy implementation of JWS signing and verification. |
|
Package jwt implements JSON Web Tokens as described in RFC 7519.
|
Package jwt implements JSON Web Tokens as described in RFC 7519. |
|
internal/errors
Package errors exist to store errors for jwt and openid packages.
|
Package errors exist to store errors for jwt and openid packages. |
|
openid
Package openid provides a specialized token that provides utilities to work with OpenID JWT tokens.
|
Package openid provides a specialized token that provides utilities to work with OpenID JWT tokens. |