jwx.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //go:generate ./gen.sh
  2. //go:generate stringer -type=FormatKind
  3. //go:generate mv formatkind_string.go formatkind_string_gen.go
  4. // Package jwx contains tools that deal with the various JWx (JOSE)
  5. // technologies such as JWT, JWS, JWE, etc in Go.
  6. //
  7. // JWS (https://tools.ietf.org/html/rfc7515)
  8. // JWE (https://tools.ietf.org/html/rfc7516)
  9. // JWK (https://tools.ietf.org/html/rfc7517)
  10. // JWA (https://tools.ietf.org/html/rfc7518)
  11. // JWT (https://tools.ietf.org/html/rfc7519)
  12. //
  13. // Examples are stored in a separate Go module (to avoid adding
  14. // dependencies to this module), and thus does not appear in the
  15. // online documentation for this module.
  16. // You can find the examples in Github at https://github.com/lestrrat-go/jwx/examples
  17. //
  18. // You can find more high level documentation at Github (https://github.com/lestrrat-go/jwx)
  19. //
  20. // FAQ style documentation can be found in the repository (https://github.com/lestrrat-go/jwx/tree/develop/v2/docs)
  21. package jwx
  22. import (
  23. "github.com/lestrrat-go/jwx/internal/json"
  24. )
  25. // DecoderSettings gives you a access to configure the "encoding/json".Decoder
  26. // used to decode JSON objects within the jwx framework.
  27. func DecoderSettings(options ...JSONOption) {
  28. // XXX We're using this format instead of just passing a single boolean
  29. // in case a new option is to be added some time later
  30. var useNumber bool
  31. for _, option := range options {
  32. //nolint:forcetypeassert
  33. switch option.Ident() {
  34. case identUseNumber{}:
  35. useNumber = option.Value().(bool)
  36. }
  37. }
  38. json.DecoderSettings(useNumber)
  39. }