jsonwebtoken

Create and decode JSON Web Tokens in Rust in a strongly typed way

Library
Cargo
v11.1.0
2,102 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
59 /100 Fair
Development Activity 52
Maintenance 16
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 82
Code Quality 85
Innovation 78
Learning Curve 75

jsonwebtoken is a Rust library for encoding and decoding JSON Web Tokens (JWTs), covering the full range of common signing algorithms — HMAC (HS256/384/512), RSA (RS/PS 256/384/512), and elliptic-curve (ES256/384, EdDSA) — with claims modeled as ordinary strongly-typed Rust structs via serde, rather than loosely-typed maps.

A distinguishing design choice is its pluggable crypto backend: consumers select either the aws_lc_rs or rust_crypto feature (or supply their own CryptoProvider), letting the library be used in environments with different cryptography requirements — including FIPS-adjacent deployments — without forking the crate itself. It also includes JWK (JSON Web Key) support for working with key sets published by identity providers.

What You Get

  • encode()/decode() functions operating on any Serialize/Deserialize claims struct instead of untyped JSON maps
  • Support for HS256/384/512, RS256/384/512, PS256/384/512, ES256/384, and EdDSA signing algorithms
  • EncodingKey/DecodingKey types for loading keys from PEM, DER, secrets, or raw components
  • A Validation struct for configuring expiry (exp), audience, issuer, and other standard-claim checks during decode
  • JWK (jwk.rs) support for parsing and working with published JSON Web Key Sets from identity providers
  • Swappable crypto backends (aws_lc_rs or rust_crypto feature, or a caller-supplied CryptoProvider) instead of one hardcoded implementation

Common Use Cases

  • Issuing and validating access/refresh tokens for a Rust web API’s authentication layer
  • Verifying tokens issued by external identity providers (Auth0, Okta, AWS Cognito) using their published JWKS
  • Building service-to-service auth where tokens carry strongly-typed custom claims (roles, tenant IDs, scopes)
  • Deploying in regulated environments that require a specific cryptography backend (e.g. FIPS-validated) via the pluggable CryptoProvider
  • Signing and verifying tokens with asymmetric keys (RSA/EC) for scenarios where the issuer and verifier are different services

Under The Hood

Architecture — The crate is organized around a small set of focused modules: encoding.rs/decoding.rs implement the top-level encode/decode entry points, header.rs models the JWT header (algorithm + type), validation.rs (~850 lines) implements claim validation (expiry, audience, issuer, leeway), jwk.rs (~850 lines) implements JSON Web Key parsing, and crypto/ plus pem/ house the per-algorithm signing/verification implementations and PEM key parsing. algorithms.rs defines the Algorithm enum that ties a JWT header’s alg field to the correct crypto backend call.

Tech Stack — Pure Rust (edition 2024, MSRV 1.88), built on serde/serde_json for claims serialization, base64 for JWT segment encoding, and the signature crate as a common trait for pluggable signing backends. Rather than hardcoding one crypto library, it depends on either aws_lc_rs or rust_crypto behind a Cargo feature flag, or accepts a caller-supplied CryptoProvider implementing the signature trait — a design that decouples the JWT logic from any single cryptography implementation.

Code Quality — Tests are organized per-algorithm-family under tests/ (hmac.rs, rsa/, ecdsa/, eddsa/, plus a dangerous.rs suite explicitly testing insecure/edge-case configurations like alg: none rejection), with benches/ for performance regression tracking. The crate is widely depended upon (150M+ cumulative downloads) and has a documented CHANGELOG tracking breaking changes across major versions, reflecting the care warranted by a security-sensitive library.

API Design — encode(&header, &claims, &encoding_key) and decode::<Claims>(&token, &decoding_key, &validation) are the only two calls most consumers need, with claims expressed as ordinary Rust structs deriving Serialize/Deserialize rather than stringly-typed maps — misspelled or missing claim fields become compile errors instead of runtime surprises. The Validation builder pattern for configuring expected audience/issuer/leeway keeps common security checks explicit and discoverable rather than buried in decode-time flags.

Used by 16 apps in this directory

Rust
98%

Stalwart

Collaboration

15,268

All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.

View details
88
Repo Health
81
Technical
65
Dependency
Built with
Rust 98%
Updated 1 weeks ago
Rust
93%
Other

Tabby

AI Code Assistants

33,924

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
55
Repo Health
78
Technical
61
Dependency
Built with
Rust 93%
Updated 4 months ago
Rust
66%
Apache 2.0

Temps

Analytics · Devops · Monitoring

865

A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.

View details
81
Repo Health
86
Technical
66
Dependency
Built with
Rust 66%
TypeScript 33%
Updated 1 weeks ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,708

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
68
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 4 months ago
Rust
83%
AGPL 3.0

Vaultwarden

Password Manager · Security

69,556

Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.

View details
89
Repo Health
69
Technical
69
Dependency
Built with
Rust 83%
Updated 1 weeks ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,441

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
72
Repo Health
75
Technical
63
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 months ago
Rust
98%
Other

Zed

Code Editors · Collaboration · Developer Tools

92,114

High-performance, multiplayer code editor built in Rust by the creators of Atom and Tree-sitter, with native AI integration and real-time collaboration.

View details
94
Repo Health
88
Technical
69
Dependency
Built with
Rust 98%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers