auth-jwt

Configure .NET Web API bearer authentication with rotating refresh tokens and JWTs.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill auth-jwt-faysilalshareef
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-jwt
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/security/auth-jwt
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill auth-jwt-faysilalshareef

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides clear, production-oriented guidance to implement JSON Web Token authentication in .NET APIs so teams can securely issue, validate, and refresh tokens without leaking secrets or leaving refresh tokens vulnerable to reuse.

Core Features & Use Cases

  • Short-lived access tokens and rotating refresh tokens to minimize the blast radius of token theft.
  • Full validation of issuer, audience, lifetime, and signing key with reduced clock skew and configurable options.
  • Token generation and rotation patterns including an ITokenService, refresh token repository, and login/refresh endpoints for Minimal APIs.
  • Claims and current-user access via a dedicated ICurrentUserService for handlers and authorization decisions.
  • Use Case: Add compliant JWT authentication to an existing .NET web API, centralize signing keys in secrets or Key Vault, and introduce refresh token rotation and revocation.

Quick Start

Configure JWT Bearer authentication in your .NET API using a JwtOptions configuration bound to user secrets or Key Vault, validate issuer/audience/lifetime/signing key, set a short access token expiry and 30 second clock skew, and implement refresh token rotation and storage.

Frequently Asked Questions about auth-jwt

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

FAQPage Schema
How do I implement JWT refresh token rotation in a .NET web API?

Implement JWT refresh token rotation in a .NET web API by using short-lived access tokens and a refresh token repository that invalidates used tokens upon each refresh cycle. This approach minimizes the blast radius of token theft by ensuring stolen refresh tokens cannot be reused.

What is the best way to validate JWT issuer and audience in .NET bearer authentication?

The best way to validate JWT issuer and audience in .NET bearer authentication is binding JwtOptions to your configuration and enforcing full validation of issuer, audience, lifetime, and signing key. You should also reduce clock skew to approximately 30 seconds to prevent token drift issues.

How do I securely store JWT signing keys in .NET using user secrets or Key Vault?

Securely store JWT signing keys in .NET by binding your authentication configuration to user secrets during development or Azure Key Vault in production. This prevents leaking secrets in source code while exposing validated signing keys to the token generation service.

Can I expose current user claims to authorization handlers in a .NET Minimal API?

You can expose current user claims to authorization handlers in a .NET Minimal API by implementing a dedicated ICurrentUserService. This service reads claims from the bearer token context, allowing handlers and authorization policies to make claim-based access decisions.

Why do I need short-lived access tokens with rotating refresh tokens?

You need short-lived access tokens with rotating refresh tokens to minimize the security impact of token theft. Short lifetimes limit the validity window of a compromised access token, while rotation ensures each refresh token is single-use, immediately revoking it after a new token is issued.

Does this JWT authentication approach work with existing .NET Minimal APIs?

Yes, this JWT authentication approach works directly with existing .NET Minimal APIs by providing token generation, refresh flows, and login endpoints specifically designed for the Minimal API architecture, allowing you to add compliant bearer authentication without restructuring your endpoints.