@snyk/jwt-cli 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -2
- package/bin/jwt-darwin-arm64 +0 -0
- package/bin/jwt-darwin-x64 +0 -0
- package/bin/jwt-linux-arm64 +0 -0
- package/bin/jwt-linux-x64 +0 -0
- package/bin/jwt.exe +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,11 @@ Your other alternative is to run a full authentication and gateway stack when de
|
|
|
13
13
|
$ npm i -g @snyk/jwt-cli
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
or the Go toolchain:
|
|
17
|
+
```shell
|
|
18
|
+
go install github.com/snyk/jwt-cli/cmd@v0.3.0
|
|
19
|
+
```
|
|
20
|
+
|
|
16
21
|
## Create a JWT
|
|
17
22
|
To create a token, first you're going to need some keys:
|
|
18
23
|
|
|
@@ -34,8 +39,38 @@ $ jwt create
|
|
|
34
39
|
eyJhbGciOiJSUzI1NiIsImtpZCI6Imp3dC1jbGkta2V5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJodHRwOi8vbG9jYWxob3N0IiwiYXpwIjoiMWVmZmJlZTUtZGY4ZS00YWU4LTlhNGQtOTJlNGYwMWE4YjQ0IiwiZW50cyI6IiIsImV4cCI6MTY0NjU3OTE1MCwiaWF0IjoxNjQ2NTc5MDkwLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0IiwicHR5cGUiOiJ1c2VyIiwic3ViIjoiZDExMDhiNmYtODM0OS00ZWQxLWI1ZTgtYWY0OTM4OWNiNWQwIn0.RfN5o30tVC-oNnoj5uDDH27TcUxSOFBXLwsd6hqJeYqm4AheV4F4OT5O9CbpK7V9WV3C41i5iN1L5WNjEOR2xtHxVb-nOmKWlwIN2_0B9s03A0FhSbeNKcKKU5K6umLL9f-H03X778i5LoArlOCrOBp6zywK8K8LIuDdGY8erY5ITs_1z8ABafakpZGlAvD2OuJdZX56zTRh_7yJ6lBGVeFWNgIoBK2QlEutVv4o9rWZUIZqsnte1SBu4tXXuk3ykSNrX4p2nFAP08Z-hg78C8ExBrAK7udxo0hdj7Dy27LF8YN0UzD7FD7dbGUyb9AMZk1Iy_lEhMUEQGHAUezq8Q
|
|
35
40
|
```
|
|
36
41
|
|
|
42
|
+
You can also serve the public key for your signed token via JWKS with:
|
|
43
|
+
```shell
|
|
44
|
+
$ jwt serve
|
|
45
|
+
Starting JWKS server at port 80
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This will make a JWKS server available at [http://localhost/.well-known/jwks.json](http://localhost/.well-known/jwks.json).
|
|
49
|
+
|
|
37
50
|
## Validate your JWT
|
|
38
|
-
|
|
51
|
+
|
|
52
|
+
You can quickly print a tokens claims using `jq`:
|
|
53
|
+
```shell
|
|
54
|
+
$ jq -R 'split(".") | .[0],.[1] | @base64d | fromjson' <<< "eyJhbGciOiJSUzI1NiIsImtpZCI6Imp3dC1jbGkta2V5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJodHRwOi8vbG9jYWxob3N0IiwiYXpwIjoiMWVmZmJlZTUtZGY4ZS00YWU4LTlhNGQtOTJlNGYwMWE4YjQ0IiwiZW50cyI6IiIsImV4cCI6MTY0NjU3OTE1MCwiaWF0IjoxNjQ2NTc5MDkwLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0IiwicHR5cGUiOiJ1c2VyIiwic3ViIjoiZDExMDhiNmYtODM0OS00ZWQxLWI1ZTgtYWY0OTM4OWNiNWQwIn0.RfN5o30tVC-oNnoj5uDDH27TcUxSOFBXLwsd6hqJeYqm4AheV4F4OT5O9CbpK7V9WV3C41i5iN1L5WNjEOR2xtHxVb-nOmKWlwIN2_0B9s03A0FhSbeNKcKKU5K6umLL9f-H03X778i5LoArlOCrOBp6zywK8K8LIuDdGY8erY5ITs_1z8ABafakpZGlAvD2OuJdZX56zTRh_7yJ6lBGVeFWNgIoBK2QlEutVv4o9rWZUIZqsnte1SBu4tXXuk3ykSNrX4p2nFAP08Z-hg78C8ExBrAK7udxo0hdj7Dy27LF8YN0UzD7FD7dbGUyb9AMZk1Iy_lEhMUEQGHAUezq8Q"
|
|
55
|
+
{
|
|
56
|
+
"alg": "RS256",
|
|
57
|
+
"kid": "jwt-cli-key",
|
|
58
|
+
"typ": "JWT"
|
|
59
|
+
}
|
|
60
|
+
{
|
|
61
|
+
"aud": "http://localhost",
|
|
62
|
+
"azp": "1effbee5-df8e-4ae8-9a4d-92e4f01a8b44",
|
|
63
|
+
"ents": "",
|
|
64
|
+
"exp": 1646579150,
|
|
65
|
+
"iat": 1646579090,
|
|
66
|
+
"iss": "http://localhost",
|
|
67
|
+
"ptype": "user",
|
|
68
|
+
"sub": "d1108b6f-8349-4ed1-b5e8-af49389cb5d0"
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Additionally there is an online tool at [jwt.io](https://jwt.io) which can
|
|
73
|
+
validate signatures.
|
|
39
74
|
|
|
40
75
|
Copy in your token then either copy in the contents of your public key PEM file or your JWK.
|
|
41
76
|
|
|
@@ -64,7 +99,7 @@ $ jwt keys --out some/other/path
|
|
|
64
99
|
|
|
65
100
|
### Create
|
|
66
101
|
```shell
|
|
67
|
-
|
|
102
|
+
$ jwt help create
|
|
68
103
|
NAME:
|
|
69
104
|
jwt create - create a jwt
|
|
70
105
|
|
|
@@ -97,6 +132,21 @@ Once you have your claims in a json file, simply use the `--claims` flag to targ
|
|
|
97
132
|
$ jwt create -claims jwt-claims.json
|
|
98
133
|
```
|
|
99
134
|
|
|
135
|
+
### Serve
|
|
136
|
+
```shell
|
|
137
|
+
$ jwt help serve
|
|
138
|
+
NAME:
|
|
139
|
+
jwt serve - serve a jwks server on a local port
|
|
140
|
+
|
|
141
|
+
USAGE:
|
|
142
|
+
jwt serve [command options] [arguments...]
|
|
143
|
+
|
|
144
|
+
OPTIONS:
|
|
145
|
+
--pem value, -p value relative path to the PEM file to serve as JWKS
|
|
146
|
+
--port value, --po value port to serve from (default: 80)
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
|
|
100
150
|
## Contributing
|
|
101
151
|
Checkout the [contribution guide](CONTRIBUTING.md).
|
|
102
152
|
|
package/bin/jwt-darwin-arm64
CHANGED
|
Binary file
|
package/bin/jwt-darwin-x64
CHANGED
|
Binary file
|
package/bin/jwt-linux-arm64
CHANGED
|
Binary file
|
package/bin/jwt-linux-x64
CHANGED
|
Binary file
|
package/bin/jwt.exe
CHANGED
|
Binary file
|