• Stars
    star
    1,066
  • Rank 43,337 (Top 0.9 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A super fast CLI tool to decode and encode JWTs built in Rust

jwt-cli

Dependabot Status

A super fast CLI tool to decode and encode JWTs built in Rust.

Continuous Integration GitHub release

jwt-cli is a command line tool to help you work with JSON Web Tokens (JWTs). Like most JWT command line tools out there, you can decode almost any JWT header and claims body. Unlike any that I've found, however, jwt-cli allows you to encode a new JWT with nearly any piece of data you can think of. Custom header values (some), custom claim bodies (as long as it's JSON, it's game), and using any secret you need.

On top of all that, it's written in Rust so it's fast and portable (windows, macOS, and linux supported right now).

Installation

Install jwt-cli via Homebrew or MacPorts (macOS), Cargo (cross-platform), and FreshPorts (FreeBSD). If you intend to use one of these methods, skip ahead.

You may also install the binary from the release page, if you're unable to use Homebrew or Cargo install methods below.

Only 64bit linux, macOS, and Windows targets are pre-built. Sorry if you're not on one of those! You'll need to build it from the source. See the contributing section on how to install and build the project.

You should install it somewhere in your $PATH. For Linux and macOS, a good place is generally /usr/local/bin. For Windows, there isn't a good place by default :(.

Homebrew

# Install jwt-cli
brew install mike-engel/jwt-cli/jwt-cli

# Ensure it worked ok by running the help command
jwt help

MacPorts

sudo port install jwt-cli

More info here.

Cargo

If your system supports it, you can install via Cargo. Make sure you have Rust and Cargo installed, following these instructions before proceeding.

cargo install jwt-cli

The binary installs to your Cargo bin path (~/.cargo/bin). Make sure your $PATH environment variable includes this path.

FreshPorts

If you're on FreeBSD, you can use the pkg tool to install jwt-cli on your system.

pkg install jwt-cli

Big thanks to Sergey Osokin, the FreeBSD contributor who added jwt-cli to the FreeBSD ports tree!

Scoop

jwt-cli is available on the Scoop main repository for Windows.

scoop install jwt-cli

Arch Linux

jwt-cli is available in the Arch Linux community repository and can be installed via pacman:

pacman -S jwt-cli

Alpine linux

Unfortunately due to static linking problems when compiling this project, jwt-cli can't run on alpine linux natively.

A workaround is to run it inside a rust docker container rather than using sh within alpine.

Usage

For usage info, use the help command.

# top level help
jwt help

# command specific help
jwt help encode

Usage as a pipe

The - argument tells jwt-cli to read from standard input:

jwt encode --secret=fake '{"hello":"world"}' | jwt decode -

It's useful when you're dealing with a chain of shell commands that produce a JWT. Pipe the result through jwt decode - to decode it.

curl <auth API> | jq -r .access_token | jwt decode -

Contributing

I welcome all issues and pull requests! This is my first project in rust, so this project almost certainly could be better written. All I ask is that you follow the code of conduct and use rustfmt to have a consistent project code style.

To get started you'll need rustc and cargo on your system. If they aren't already installed, I recommend rustup to get both!

Building and running the project

Once you have both installed, I recommend running the tests to make sure all is well from the start.

# run the tests
cargo test

If it built without any errors, you should be able to run the command via cargo.

cargo run -- help

Or, if you prefer a release build:

cargo run --release -- help

Code of conduct

Changelog

License

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Mike Engel
Mike Engel

πŸ’» πŸ’¬ πŸ“– πŸ€” 🚧 πŸ‘€ ⚠️ πŸ›
Kyle Burton
Kyle Burton

πŸ’»
Aaron Schaef
Aaron Schaef

πŸ’»
hughsimpson
hughsimpson

πŸ’» ⚠️
Mat Kelly
Mat Kelly

πŸ’» πŸ›
Jason
Jason

πŸ›
Ben Berry
Ben Berry

πŸ›
Kevin Lanni
Kevin Lanni

πŸ“–
Kosta Krauth
Kosta Krauth

πŸ’» ⚠️ πŸ“–
codedust
codedust

πŸ’» πŸ€” ⚠️
Liz Frost
Liz Frost

πŸ’»
Carl Harris
Carl Harris

πŸ’» ⚠️
Yusuke Kominami
Yusuke Kominami

πŸ’» πŸ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

a11y-css-reset

A small set of global rules to make things accessible and reset default styling
CSS
261
star
2

styled-typography

Typograpy components for react and styled-components
TypeScript
128
star
3

swiftvg

Convert SVG path data to a Swift 3 UIBezierPath
JavaScript
109
star
4

babel-plugin-bucklescript

Write ReasonML and Bucklescript in your existing babel projects
JavaScript
77
star
5

bkmrkd

Bkmrkd is a self-hosted, lightweight bookmarking service run on node.js and rethinkdb
JavaScript
51
star
6

Barnacal

A simple menu bar app for viewing a calendar
JavaScript
37
star
7

floating-label-react

A floating-label component using react without any dependencies
CSS
26
star
8

preact-cli-typescript-sample

An example of how to use typescript with preact-cli and all its goodies
TypeScript
17
star
9

gistcard

Show better gist previews in twitter with a code snippet and a link to the gist
TypeScript
13
star
10

accept-language-rs

A tiny library for parsing the Accept-Language header from browsers
Rust
12
star
11

now-importer

Easily import your static websites into ZEIT's now platform
Rust
8
star
12

locale

A polyfill to understand your users' preferred languages
Rust
7
star
13

homebrew-jwt-cli

The official homebrew tap for jwt-cli. Because it's not popular enough on its own.
Ruby
5
star
14

hyper-base16-ocean-dark

A Base 16 Ocean Hypeterm theme plugin
JavaScript
4
star
15

split-view-test

Test case for odd split view behavior in SwiftUI
Swift
2
star
16

gotham-router-composition

A small example demonstrating one way to compose a router in gotham
Rust
1
star
17

vimfiles

My .vim directory and .vimrc
Vim Script
1
star
18

mike-engel.com

source for mike-engel.com
SCSS
1
star
19

passablewords-js

A password validation library which checks a password against a million of the most common as well as it's ability to be cracked
JavaScript
1
star
20

vscode-simple-ocean

A minimal syntax theme based off of Base16 Ocean for VS Code
1
star
21

atom-simple-base16-ocean

A simplified base16 ocean theme. 4 colors and that's it.
CSS
1
star