Git Product home page Git Product logo

jwt's Introduction

jwt CLI

Go Report Card license GitHub release

A JWT CLI written in Go.

Also includes:

Installation

Download executable for your OS from Releases

  • Works on most platforms: Windows, iOS, Linux etc

Alternative installation (with Go):

go get -u github.com/peteretelej/jwt

Usage

Decode token and print details in human readable format

  • Add headers to sections
  • Parse timestamps
  • Provide human readable durations eg ( expires in 1yr )
./jwt TOKEN

Verify if token is signed by a secret

./jwt --secret SECRET TOKEN 

Generate JWT token

./jwt --secret demopass --sign '{"user": "John Doe"}' 

Specify an expiry period for the generated token

./jwt  --secret demopass --exp 1y --sign '{"user": "John Doe"}'
  • Supports durations (eg year to second) such as yr, mo, w, d, h,m,s
  • examples: --exp 6mo (6 months), --exp 2w (2 weeks)

Tips

If you don't want to paste secret as plain text in command line:

  • do not specify the --secret argument, it will prompt pasting or typing secret (does not print the secret)
./jwt --sign '{"user": "Jane Doe"}'
Please enter a secret to sign the JWT (and press Enter)
Usage Examples

Generating a signed JWT token

./jwt --sign '{"name": "John Doe"}' --secret demopass --exp 2w

image

Decode JWT token

./jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc3NTkyNzUsIm5hbWUiOiJKb2huIERvZSJ9.SF2XbD6QpxxcV95Oa_AC1oXysfWcF9gmyMEaNAHagP0

image

Verifying a token's signing key

./jwt --secret demopass eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc3NTkyNzUsIm5hbWUiOiJKb2huIERvZSJ9.SF2XbD6QpxxcV95Oa_AC1oXysfWcF9gmyMEaNAHagP0

image

Decoding a token with multiple standard claims

./jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNjIxMjY5Mjg2LCJleHAiOjE2Mzk3NTg4ODYsIm5iZiI6MTYyMzk0NzY4Nn0.GR5pGSiJZk3Ls0A429K3HIZfsmQqGnyIhPusDT5F5BU

image

License: MIT

jwt's People

Contributors

peteretelej avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

jwt's Issues

Usage examples

Examples:

Generating a signed JWT token

./jwt --sign '{"name": "John Doe"}' --secret demopass --exp 2w

image

Decode JWT token

./jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc3NTkyNzUsIm5hbWUiOiJKb2huIERvZSJ9.SF2XbD6QpxxcV95Oa_AC1oXysfWcF9gmyMEaNAHagP0

image

Verifying a token's signing key

./jwt --secret demopass eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc3NTkyNzUsIm5hbWUiOiJKb2huIERvZSJ9.SF2XbD6QpxxcV95Oa_AC1oXysfWcF9gmyMEaNAHagP0

image

Decoding a token with multiple standard claims

./jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNjIxMjY5Mjg2LCJleHAiOjE2Mzk3NTg4ODYsIm5iZiI6MTYyMzk0NzY4Nn0.GR5pGSiJZk3Ls0A429K3HIZfsmQqGnyIhPusDT5F5BU

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.