Git Product home page Git Product logo

jwt-webtool's Introduction

JWT Web tool

This is the source code for a web tool that can decode JWT, verify signed JWT, decrypt encrypted JWT, and create signed or encrypted JWT. It works nicely for lots of cases. It also has a few limitations; details below.

screengrab

License

This code is Copyright (c) 2019-2021 Google LLC, and is released under the Apache Source License v2.0. For information see the LICENSE file.

Purpose

I built this as a tool that might be helpful to developers learning JWT, or experimenting with ways to use JWT. The output of this repo is currently running here.

Disclaimer

This tool is not an official Google product, nor is it part of an official Google product.

Limitations

This tool has some limitations:

  • For signed JWT, the tool handles JWT that use ECDSA (ES256, ES384, ES512), RSA (RS256, RS384, RS512, PS256, PS384, PS512) or HMAC algorithms (HS256, HS384, HS512).

  • For encrypted JWT, specifically for key encryption, it handles JWT that use RSA keys and RSA algorithms (RSA-OAEP, RSA-OAEP-256), JWT that use EC keys and various ECDH algorithms (ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A256KW) as well as JWT that use the PBES2 algorithms. It does not currently support the "dir" alg type. It supports all types of enc algorithms.

  • In either case (signed or encrypted), this tool does not handle crit headers, nor will it extract the certificate from an x5c header. Nor will it check thumbprints of an x5t header.

  • This tool uses EcmaScript v9, and webcrypto, which means it will run only on modern, current browsers.

Design

This is a single-page web app. It has no "backend" supporting it. All JWT signing and verifying, or encrypting or decrypting, happens within the browser. Anything a user pastes into the UI never leaves the browser. It just needs a few static files.

There's a shortcut: if you open the url with ?JWT_HERE, it will decode that JWT. It saves you a step, pasting in your own JWT. If you're paranoid you can also use the # as a separator.

You may want to fork this and bundle it into an intranet, to allow developers within a company to experiment with JWT. You can also run it from a file:// URL.

From my perspective, there's no security issue with using the publicly hosted tool, but your company's security auditors may not agree..

Dependencies

The web app depends on

Build Dependencies

This tool uses webpack v4 for bundling the assets.

Please send pull requests

This is my first webpack project, so if anyone has some constructive feedback on my webpack config, how to improve or optimize it, please let me know. PR's will be appreciated.

For example, the JS bundle is about 1mb and the css bundle is 400kb. If there is a better way to optimize this, I am interested to learn.

Developing

If you fork this repo to mess with the code, here's what I advise.

To build a "development" distribution:

npm run devbuild

During development, I prefer to use the webpack "watch" capability, which rebuilds as I modify the source code. For that, open a Chrome browser tab to file:///path/to/dist/index.html . Then in a terminal,

npm run watch

The above command will run "forever", and will rebundle when any source file changes. When you save a file, wait a few seconds for the build, maybe 5 seconds, and then just click the reload button in the browser tab, to see the updates.

To build a production distribution:

npm run build

Bugs / Feature Gaps

  • The support for key-encryption algorithms is incomplete. Missing are: AES based key-wrapping algorithms, and direct keys.

  • When using ECDH encryption, the tool always chooses the P-256 curve.

  • It is not possible to use an x509v3 certificate for the source of the public key.

jwt-webtool's People

Contributors

dinochiesa avatar dependabot[bot] avatar antifob avatar mormegil-cz avatar

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.