• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H26-Sep-2021-

bench/H26-Sep-2021-

cmd/jwx/H26-Sep-2021-

docs/H26-Sep-2021-

examples/H26-Sep-2021-

internal/H26-Sep-2021-

jwa/H26-Sep-2021-

jwe/H26-Sep-2021-

jwk/H26-Sep-2021-

jws/H26-Sep-2021-

jwt/H26-Sep-2021-

scripts/H26-Sep-2021-

x25519/H26-Sep-2021-

.gitignoreH A D26-Sep-2021382

.golangci.ymlH A D26-Sep-20211.5 KiB

ChangesH A D26-Sep-202122.7 KiB

LICENSEH A D26-Sep-20211.1 KiB

MakefileH A D26-Sep-20212.3 KiB

README.mdH A D26-Sep-20216.6 KiB

format.goH A D26-Sep-20212.5 KiB

formatkind_string_gen.goH A D26-Sep-2021726

go.modH A D26-Sep-2021628

go.sumH A D26-Sep-20216.3 KiB

jwx.goH A D26-Sep-20211.6 KiB

jwx_test.goH A D26-Sep-202115.1 KiB

options.goH A D26-Sep-2021596

README.md

1# github.com/lestrrat-go/jwx ![](https://github.com/lestrrat-go/jwx/workflows/CI/badge.svg) [![Go Reference](https://pkg.go.dev/badge/github.com/lestrrat-go/jwx.svg)](https://pkg.go.dev/github.com/lestrrat-go/jwx) [![codecov.io](http://codecov.io/github/lestrrat-go/jwx/coverage.svg?branch=main)](http://codecov.io/github/lestrrat-go/jwx?branch=main)
2
3Various libraries implementing various JWx technologies. Please click on the package names in the table below to find the synopsis/description for each package.
4
5| Package name                                              | Notes                                           |
6|-----------------------------------------------------------|-------------------------------------------------|
7| [jwt](https://github.com/lestrrat-go/jwx/tree/main/jwt) | [RFC 7519](https://tools.ietf.org/html/rfc7519) |
8| [jwk](https://github.com/lestrrat-go/jwx/tree/main/jwk) | [RFC 7517](https://tools.ietf.org/html/rfc7517) + [RFC 7638](https://tools.ietf.org/html/rfc7638) |
9| [jwa](https://github.com/lestrrat-go/jwx/tree/main/jwa) | [RFC 7518](https://tools.ietf.org/html/rfc7518) |
10| [jws](https://github.com/lestrrat-go/jwx/tree/main/jws) | [RFC 7515](https://tools.ietf.org/html/rfc7515) + [RFC 7797](https://tools.ietf.org/html/rfc7797) |
11| [jwe](https://github.com/lestrrat-go/jwx/tree/main/jwe) | [RFC 7516](https://tools.ietf.org/html/rfc7516) |
12
13# How to Use
14
15* [API documentation](https://pkg.go.dev/github.com/lestrrat-go/jwx)
16* [How-to style documentation](./docs)
17* [Runnable Examples](./examples)
18
19# Description
20
21## History
22
23My goal was to write a server that heavily uses JWK and JWT. At first glance
24the libraries that already exist seemed sufficient, but soon I realized that
25
261. To completely implement the protocols, I needed the entire JWT, JWK, JWS, JWE (and JWA, by necessity).
272. Most of the libraries that existed only deal with a subset of the various JWx specifications that were necessary to implement their specific needs
28
29For example, a certain library looks like it had most of JWS, JWE, JWK covered, but then it lacked the ability to include private claims in its JWT responses. Another library had support of all the private claims, but completely lacked in its flexibility to generate various different response formats.
30
31Because I was writing the server side (and the client side for testing), I needed the *entire* JOSE toolset to properly implement my server, **and** they needed to be *flexible* enough to fulfill the entire spec that I was writing.
32
33So here's `github.com/lestrrat-go/jwx`. This library is extensible, customizable, and hopefully well organized to the point that it is easy for you to slice and dice it.
34
35## Why would I use this library?
36
37There are several other major Go modules that handle JWT and related data formats,
38so why should you use this library?
39
40From a purely functional perspective, the only major difference is this:
41Whereas most other projects only deal with what they seem necessary to handle
42JWTs, this module handles the entire spectrum of JWS, JWE, JWK, and JWT.
43
44That is, if you need to not only parse JWTs, but also to control JWKs, or
45if you need to handle payloads that are NOT JWTs, you should probably consider
46using this module.
47
48Next, from an implementation perspective, this module differs significantly
49from others in that it tries very hard to expose only the APIs, and not the
50internal data. For example, individual JWT claims are not accessible through
51struct field lookups. You need to use one of the getter methods.
52
53This is because this library takes the stance that the end user is fully capable
54and even willing to shoot themselves on the foot when presented with a lax
55API. By making sure that users do not have access to open structs, we can protect
56users from doing silly things like creating _incomplete_ structs, or access the
57structs concurrently without any protection. This structure also allows
58us to put extra smarts in the structs, such as doing the right thing when
59you want to parse / write custom fields (this module does not require the user
60to specify alternate structs to parse objects with custom fields)
61
62In the end I think it comes down to your usage pattern, and priorities.
63Some general guidelines that come to mind are:
64
65* If you want a single library to handle everything JWx, such as using JWE, JWK, JWS, handling [auto-refreshing JWKs](https://github.com/lestrrat-go/jwx/blob/main/docs/04-jwk.md#auto-refreshing-remote-keys), use this module.
66* If you want to honor all possible custom fields transparently, use this module.
67* If you want a standardized clean API, use this module.
68
69Otherwise, feel free to choose something else.
70
71# Command Line Tool
72
73Since v1.1.1 we have a command line tool `jwx` (*). With `jwx` you can create JWKs (from PEM files, even), sign and verify JWS message, encrypt and decrypt JWE messages, etc.
74
75(*) Okay, it existed since a long time ago, but it was never useful.
76
77## Installation
78
79```
80go install github.com/lestrrat-go/jwx/cmd/jwx
81```
82
83# Caveats
84
85## Backwards Compatibility Notice
86
87### Users of github.com/lestrrat/go-jwx
88
89Uh, why are you using such an ancient version? You know that repository is archived for a reason, yeah? Please use the new version.
90
91### Pre-1.0.0 users
92
93The API has been reworked quite substantially between pre- and post 1.0.0 releases. Please check out the [Changes](./Changes) file (or the [diff](https://github.com/lestrrat-go/jwx/compare/v0.9.2...v1.0.0), if you are into that sort of thing)
94
95### v1.0.x users
96
97The API has gone under some changes for v1.1.0. If you are upgrading, you might want to read the relevant parts in the [Changes](./Changes) file.
98
99# Contributions
100
101## Issues
102
103For bug reports and feature requests, please try to follow the issue templates as much as possible.
104For either bug reports or feature requests, failing tests are even better.
105
106## Pull Requests
107
108Please make sure to include tests that excercise the changes you made.
109
110If you are editing auto-generated files (those files with the `_gen.go` prefix, please make sure that you do the following:
111
1121. Edit the generator, not the generated files (e.g. internal/cmd/genreadfile/main.go)
1132. Run `make generate` (or `go generate`) to generate the new code
1143. Commit _both_ the generator _and_ the generated files
115
116## Discussions / Usage
117
118Please try [discussions](https://github.com/lestrrat-go/jwx/discussions) first.
119
120# Credits
121
122* Work on this library was generously sponsored by HDE Inc (https://www.hde.co.jp)
123* Lots of code, especially JWE was taken from go-jose library (https://github.com/square/go-jose)
124* Lots of individual contributors have helped this project over the years. Thank each and everyone of you very much.
125
126