Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

docs(command_tool): optimize the usage demo more clearer. #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions cmd/jwt/README.md
Original file line number Diff line number Diff line change
@@ -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.