From b74c549d04ca0beebd5b21de3dfc24256639274f Mon Sep 17 00:00:00 2001 From: davidcui Date: Sun, 27 Sep 2020 17:52:37 +0800 Subject: [PATCH] docs(command_tool): optimize the usage demo more clear. --- cmd/jwt/README.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cmd/jwt/README.md b/cmd/jwt/README.md index d9d06e72..fe88f488 100644 --- a/cmd/jwt/README.md +++ b/cmd/jwt/README.md @@ -1,20 +1,32 @@ -`jwt` command-line tool -======================= +# `jwt` command-line tool This is a simple tool to sign, verify and show JSON Web Tokens from the command line. The following will create and sign a token, then verify it and output the original claims: - echo {\"foo\":\"bar\"} | ./jwt -key ../../test/sample_key -alg RS256 -sign - | ./jwt -key ../../test/sample_key.pub -alg RS256 -verify - +- To sign a claim object -Key files should be in PEM format. Other formats are not supported by this tool. +```bash +echo {\"foo\":\"bar\"} | ./jwt -key ../../test/sample_key -alg RS256 -sign - +``` -To simply display a token, use: +- To verify a token - echo $JWT | ./jwt -show - +```bash +JWT=$(echo {\"foo\":\"bar\"} | ./jwt -key ../../test/sample_key -alg RS256 -sign -) +echo ${JWT} | ./jwt -key ../../test/sample_key.pub -alg RS256 -verify - +``` -You can install this tool with the following command: +- To simply display a token - go install github.com/dgrijalva/jwt-go/cmd/jwt +```bash +JWT=$(echo {\"foo\":\"bar\"} | ./jwt -key ../../test/sample_key -alg RS256 -sign -) +echo $JWT | ./jwt -show - +``` +## Installation + +Simply: `go install github.com/dgrijalva/cmd/jwt` + +Or you can download the code, compile it, and put the result wherever you like.