Skip to content

Commit 0e3fa78

Browse files
committed
better error message
1 parent 36af20b commit 0e3fa78

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ jwtui [OPTIONS] [TOKEN]
129129

130130
# Start UI with prefilled token to decode and JWKS secret from URL
131131
jwtui -S $(curl https://domain.auth0.com/.well-known/jwks.json) [TOKEN]
132+
# if your provider has a different URL for JWKS, look for `jwks_uri` in https://your.idp.com/.well-known/openid-configuration
132133

133134
# Print decoded token to stdout with HMAC plain text secret
134135
jwtui -s -S 'plain_text_secret' [TOKEN]
@@ -140,7 +141,7 @@ jwtui -sn [TOKEN]
140141
jwtui -s -S 'b64:eW91ci0yNTYtYml0LXNlY3JldAo=' [TOKEN]
141142

142143
# Print decoded token to stdout as JSON
143-
jwtui -sj -S '@./secret.pem' [TOKEN]
144+
jwtui -j -S '@./secret.pem' [TOKEN]
144145

145146
# Print decoded token to stdout with JWKS secret from url
146147
jwtui -s -S $(curl https://domain.auth0.com/.well-known/jwks.json) [TOKEN]
@@ -156,7 +157,7 @@ Options:
156157
- `-S, --secret <SECRET>` Secret for validating the JWT. Can be text, file path (beginning with @) or base64 encoded string (beginning with b64:) [default: ]
157158
- `-s, --stdout` Print to STDOUT instead of starting the CLI in TUI mode
158159
- `-n, --no-verify` Do not validate the signature of the JWT when printing to STDOUT.
159-
- `-j, --json` Format STDOUT as JSON
160+
- `-j, --json` Print to STDOUT as JSON
160161
- `-t, --tick-rate <TICK_RATE>` Set the tick rate (milliseconds): the lower the number the higher the FPS. Must be less than 1000 [default: 250]
161162
- `-h, --help` Print help
162163
- `-V, --version` Print version

src/app/jwt_decoder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,9 @@ mod tests {
371371
let (decode_only, verified_token_data) = decode_token(&args);
372372

373373
assert!(decode_only.is_ok());
374-
assert!(verified_token_data
375-
.unwrap_err()
376-
.to_string()
377-
.contains("The JWT provided has an invalid signature: InvalidSignature"));
374+
assert!(verified_token_data.unwrap_err().to_string().contains(
375+
"The JWT provided has an invalid signature. Provide a valid secret: InvalidSignature"
376+
));
378377

379378
let decode_only_token = decode_only.unwrap();
380379

src/app/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn map_external_error(ext_err: &Error) -> String {
174174
"The JWT provided is invalid".to_string()
175175
}
176176
ErrorKind::InvalidSignature => {
177-
"The JWT provided has an invalid signature".to_string()
177+
"The JWT provided has an invalid signature. Provide a valid secret".to_string()
178178
}
179179
ErrorKind::InvalidRsaKey(_) => {
180180
"The secret provided isn't a valid RSA key".to_string()

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Cli {
4444
/// Do not validate the signature of the JWT when printing to STDOUT.
4545
#[arg(short, long, value_parser, default_value_t = false)]
4646
pub no_verify: bool,
47-
/// Format STDOUT as JSON.
47+
/// Print to STDOUT as JSON.
4848
#[arg(short, long, value_parser, default_value_t = false)]
4949
pub json: bool,
5050
/// Set the tick rate (milliseconds): the lower the number the higher the FPS. Must be less than 1000.
@@ -66,7 +66,7 @@ fn main() -> Result<()> {
6666
panic!("Tick rate must be below 1000");
6767
}
6868

69-
if cli.stdout && cli.token.is_some() {
69+
if (cli.stdout || cli.json) && cli.token.is_some() {
7070
to_stdout(cli);
7171
} else {
7272
// The UI must run in the "main" thread

0 commit comments

Comments
 (0)