터미널에서 jwt-cli로 JWT 만들기 또는 디코딩

3311 단어 JWTtech

mike-engel/jwt-cli


Rust제 JWT를 만들거나 디코딩하는 물건입니다.

글판


$ jwt --version
jwt 4.0.0

설치하다.


이 일대를 참조하시오.
https://github.com/mike-engel/jwt-cli#homebrew

사용법


디코딩


$ jwt decode -h
jwt-decode 
Decode a JWT

USAGE:
    jwt decode [FLAGS] [OPTIONS] <jwt>

FLAGS:
    -h, --help       Prints help information
        --iso8601    display unix timestamps as ISO 8601 dates
    -j, --json       render decoded JWT as JSON
    -V, --version    Prints version information

OPTIONS:
    -A, --alg <algorithm>    the algorithm to use for signing the JWT [default: HS256]  [possible values: HS256, HS384,
                             HS512, RS256, RS384, RS512, ES256, ES384]
    -S, --secret <secret>    the secret to validate the JWT with. Can be prefixed with @ to read from a binary file
                             [default: ]

ARGS:
    <jwt>    the jwt to decode

부호화


$ jwt encode -h
jwt-encode 
Encode new JWTs

USAGE:
    jwt encode [FLAGS] [OPTIONS] --secret <secret> [--] [json]

FLAGS:
    -h, --help       Prints help information
        --no-iat     prevent an iat claim from being automatically added
    -V, --version    Prints version information

OPTIONS:
    -A, --alg <algorithm>         the algorithm to use for signing the JWT [default: HS256]  [possible values: HS256,
                                  HS384, HS512, RS256, RS384, RS512, ES256, ES384]
    -a, --aud <audience>          the audience of the token
    -e, --exp <expires>           the time the token should expire, in seconds or systemd.time string [default: +30 min]
    -i, --iss <issuer>            the issuer of the token
        --jti <jwt_id>            the jwt id of the token
    -k, --kid <kid>               the kid to place in the header
    -n, --nbf <not_before>        the time the JWT should become valid, in seconds or systemd.time string
    -P, --payload <payload>...    a key=value pair to add to the payload
    -S, --secret <secret>         the secret to sign the JWT with. Can be prefixed with @ to read from a binary file
    -s, --sub <subject>           the subject of the token
    -t, --typ <type>              the type of token being encoded [possible values: JWT]

ARGS:
    <json>    the json payload to encode

시험해 보다


부호화


$ jwt encode -P 'hello=jwt' --secret "secret"
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoZWxsbyI6Imp3dCIsImlhdCI6MTYzNDI5MTE3MX0.5JXMhypffjaZ6tYzNu_XFi3lFxHCXSZGKX7jzVeEAPE

디코딩


$ jwt decode eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoZWxsbyI6Imp3dCIsImlhdCI6MTYzNDI5MTE3MX0.5JXMhypffjaZ6tYzNu_XFi3lFxHCXSZGKX7jzVeEAPE

Token header
------------
{
  "typ": "JWT",
  "alg": "HS256"
}

Token claims
------------
{
  "hello": "jwt",
  "iat": 1634291171
}

좋은 웹페이지 즐겨찾기