@snyk/jwt-cli 0.3.0 → 0.4.0

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 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/jwt@v0.3.1
19
+ ```
20
+
16
21
  ## Create a JWT
17
22
  To create a token, first you're going to need some keys:
18
23
 
@@ -43,7 +48,29 @@ Starting JWKS server at port 80
43
48
  This will make a JWKS server available at [http://localhost/.well-known/jwks.json](http://localhost/.well-known/jwks.json).
44
49
 
45
50
  ## Validate your JWT
46
- Create some keys and a token then head over to [jwt.io](https://jwt.io).
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.
47
74
 
48
75
  Copy in your token then either copy in the contents of your public key PEM file or your JWK.
49
76
 
@@ -80,13 +107,13 @@ USAGE:
80
107
  jwt create [command options] [arguments...]
81
108
 
82
109
  OPTIONS:
83
- --pem value relative path to the PEM file for the private key
84
- --claims value relative path to a JSON file containing claims
110
+ --claims value, -c value relative path to a JSON file containing claims
111
+ --identity_file value, -i value relative path to the identity (PEM private key) file (default: ./jwt_private_key.pem)
85
112
  ```
86
113
 
87
114
  You can change the signing PEM with the following:
88
115
  ```shell
89
- $ jwt create --pem some/other/path/private.pem
116
+ $ jwt create -i some/other/path/private.pem
90
117
  ```
91
118
 
92
119
  You can change the claims in the JWT by creating a claims JSON file:
@@ -102,7 +129,7 @@ You can change the claims in the JWT by creating a claims JSON file:
102
129
 
103
130
  Once you have your claims in a json file, simply use the `--claims` flag to target it:
104
131
  ```shell
105
- $ jwt create -claims jwt-claims.json
132
+ $ jwt create -c jwt-claims.json
106
133
  ```
107
134
 
108
135
  ### Serve
@@ -115,9 +142,8 @@ USAGE:
115
142
  jwt serve [command options] [arguments...]
116
143
 
117
144
  OPTIONS:
118
- --pem value, -p value relative path to the PEM file to serve as JWKS
119
- --port value, --po value port to serve from (default: 80)
120
-
145
+ --identity_file value, -i value relative path to the identity (PEM private key) file (default: ./jwt_private_key.pem)
146
+ --port value, -p value port to serve from (default: 80)
121
147
  ```
122
148
 
123
149
  ## Contributing
Binary file
Binary file
Binary file
package/bin/jwt-linux-x64 CHANGED
Binary file
package/bin/jwt.exe CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snyk/jwt-cli",
3
- "version": "v0.3.0",
3
+ "version": "v0.4.0",
4
4
  "description": "jwt-cli is a little command line tool to create jwts locally",
5
5
  "bin": {
6
6
  "jwt": "bin/jwt"