站点更新:2018-03-27 18:22:46
This commit is contained in:
parent
835abbd1b2
commit
5ac2f912c7
64
README.md
64
README.md
@ -1,6 +1,8 @@
|
||||
# JWT
|
||||
> This is a simple tool to sign, verify and show JSON Web Tokens ([JWT](http://jwt.io/)) from the command line, base [jwt-go](https://github.com/dgrijalva/jwt-go).
|
||||
|
||||
![image](https://wx4.sinaimg.cn/large/687148dbly1fprjoxvd2gg213g0od7eq.gif)
|
||||
|
||||
# Install
|
||||
|
||||
```
|
||||
@ -29,4 +31,66 @@ Flags:
|
||||
-v, --version show version of the jwt.
|
||||
|
||||
Use "jwt [command] --help" for more information about a command.
|
||||
|
||||
```
|
||||
|
||||
## sign JWT
|
||||
|
||||
```
|
||||
➜ jwt sign -h
|
||||
|
||||
签名 JWT token 并复制到剪切板
|
||||
标记 * 号的 flag 为必须项
|
||||
|
||||
Usage:
|
||||
jwt sign [flags]
|
||||
|
||||
Flags:
|
||||
-c, --claims argList add additional claims. may be used more than once (default {})
|
||||
-d, --data string * path or json to claims object to sign, '-' to read from clipboard, or '+' to use only -claim args
|
||||
-H, --header argList add additional header params. may be used more than once (default {})
|
||||
-h, --help help for sign
|
||||
-k, --key string * path of keyfile or key argument
|
||||
|
||||
Global Flags:
|
||||
--config string config file (default is $HOME/.jwt.yaml)
|
||||
```
|
||||
|
||||
## show JWT
|
||||
|
||||
```
|
||||
➜ jwt show -h
|
||||
|
||||
查看 JWT Token 内容
|
||||
标记 * 号的 flag 为必须项
|
||||
|
||||
Usage:
|
||||
jwt show [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for show
|
||||
-t, --token string * path or arg of JWT token to verify, '-' to read from clipboard
|
||||
|
||||
Global Flags:
|
||||
--config string config file (default is $HOME/.jwt.yaml)
|
||||
```
|
||||
|
||||
## verify JWT
|
||||
|
||||
```
|
||||
➜ jwt verify -h
|
||||
|
||||
验证 JWT token 是否有效
|
||||
标记 * 号的 flag 为必须项
|
||||
|
||||
Usage:
|
||||
jwt verify [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for verify
|
||||
-k, --key string * path of keyfile or key argument
|
||||
-t, --token string * path or arg of JWT token to verify, '-' to read from clipboard
|
||||
|
||||
Global Flags:
|
||||
--config string config file (default is $HOME/.jwt.yaml)
|
||||
```
|
@ -31,9 +31,10 @@ import (
|
||||
// showCmd represents the show command
|
||||
var showCmd = &cobra.Command{
|
||||
Use: "show",
|
||||
Short: "查看 JWT Token",
|
||||
Short: "JWT Token 查看",
|
||||
Long: `
|
||||
查看 JWT Token`,
|
||||
查看 JWT Token 内容
|
||||
标记 * 号的 flag 为必须项`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := token.ShowToken(cmd); err != nil {
|
||||
fmt.Println(err)
|
||||
@ -45,5 +46,5 @@ var showCmd = &cobra.Command{
|
||||
func init() {
|
||||
rootCmd.AddCommand(showCmd)
|
||||
|
||||
showCmd.Flags().StringP("token", "t", "", "path or arg of JWT token to verify, '-' to read from clipboard")
|
||||
showCmd.Flags().StringP("token", "t", "", "* path or arg of JWT token to verify, '-' to read from clipboard")
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ var signCmd = &cobra.Command{
|
||||
Use: "sign",
|
||||
Short: "JWT 签名",
|
||||
Long: `
|
||||
JWT 签名`,
|
||||
签名 JWT token 并复制到剪切板
|
||||
标记 * 号的 flag 为必须项`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := token.SignToken(cmd); err != nil {
|
||||
fmt.Println(err)
|
||||
@ -45,8 +46,8 @@ JWT 签名`,
|
||||
func init() {
|
||||
rootCmd.AddCommand(signCmd)
|
||||
|
||||
signCmd.Flags().StringP("data", "d", "", "path or json to claims object to sign, '-' to read from clipboard, or '+' to use only -claim args")
|
||||
signCmd.Flags().StringP("key", "k", "", "path of keyfile or key argument")
|
||||
signCmd.Flags().StringP("data", "d", "", "* path or json to claims object to sign, '-' to read from clipboard, or '+' to use only -claim args")
|
||||
signCmd.Flags().StringP("key", "k", "", "* path of keyfile or key argument")
|
||||
signCmd.Flags().VarP(make(token.ArgList), "claims", "c", "add additional claims. may be used more than once")
|
||||
signCmd.Flags().VarP(make(token.ArgList), "header", "H", "add additional header params. may be used more than once")
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ var verifyCmd = &cobra.Command{
|
||||
Use: "verify",
|
||||
Short: "JWT token 验证",
|
||||
Long: `
|
||||
JWT token 验证`,
|
||||
验证 JWT token 是否有效
|
||||
标记 * 号的 flag 为必须项`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := token.VerifyToken(cmd); err != nil {
|
||||
fmt.Println(err)
|
||||
@ -47,6 +48,6 @@ JWT token 验证`,
|
||||
func init() {
|
||||
rootCmd.AddCommand(verifyCmd)
|
||||
|
||||
verifyCmd.Flags().StringP("token", "t", "", "path or arg of JWT token to verify, '-' to read from clipboard")
|
||||
verifyCmd.Flags().StringP("key", "k", "", "path of keyfile or key argument")
|
||||
verifyCmd.Flags().StringP("token", "t", "", "* path or arg of JWT token to verify, '-' to read from clipboard")
|
||||
verifyCmd.Flags().StringP("key", "k", "", "* path of keyfile or key argument")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user