rust-backend-auth

Implement Argon2 password hashing and JWT authentication middleware for Axum backends.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/caioniehues/dotfiles --skill rust-backend-auth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-backend-auth
Source: https://github.com/caioniehues/dotfiles/tree/main/skills/rust-backend-auth
Command: npx skills add https://github.com/caioniehues/dotfiles --skill rust-backend-auth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Establishes secure authentication using Argon2 password hashing, JWT-based tokens, and middleware that injects authenticated users into request context.

Core Features & Use Cases

  • Password hashing with Argon2id and salted hashes.
  • Token management with JWT creation/validation and token claims validation.
  • Middleware that injects user context into request lifecycles.

Quick Start

Use this pattern to add login/register flows with JWTs and protected routes.

Frequently Asked Questions about rust-backend-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JWT authentication in a Rust backend?

JWT authentication in Rust backends involves creating tokens with claims like expiration, issuer, and audience, then validating them on protected routes. This Skill provides middleware patterns for Axum/Tower-based services that decode and inject user context into requests, handling clock-skew and token expiry checks automatically.

What's the best way to hash passwords securely in Rust?

Argon2 password hashing with salted hashes is the industry standard for secure password storage. This Skill implements Argon2id hashing so passwords are protected even if your database is compromised, and provides verification logic for login flows.

Can I protect routes with middleware that validates user tokens?

Yes. This Skill provides middleware that validates JWT tokens, checks expiration and issuer/audience claims, handles clock-skew tolerance, and injects authenticated user context into request extensions so downstream handlers access user data directly.

How do I build login and logout flows with JWTs in Axum?

Login flows hash user passwords with Argon2, generate JWT tokens with configurable claims, and return them to clients. Logout is stateless with JWTs—clients discard tokens; this Skill shows the token generation and validation patterns for Axum/Tower backends.

Does JWT validation handle clock skew between servers?

Yes. Clock skew—minor time differences between servers—can cause valid tokens to be rejected. This Skill implements configurable clock-skew tolerance during JWT validation so tokens remain valid across distributed systems.

What claims does this JWT implementation validate?

This Skill validates expiration (exp), issuer (iss), and audience (aud) claims in JWTs. These claims prevent token misuse across different services and ensure tokens don't outlive their intended lifespan.