| Crates.io | nextera_jwt |
| lib.rs | nextera_jwt |
| version | 0.1.10 |
| created_at | 2024-12-11 16:37:22.266097+00 |
| updated_at | 2025-07-24 08:33:40.475866+00 |
| description | Next Era JSON Web Token Attribute |
| homepage | |
| repository | https://github.com/Next-Era-Myanmar/nextera_jwt |
| max_upload_size | |
| id | 1480273 |
| size | 92,323 |
This crate provides procedural macro attributes to easily secure Actix Web endpoints using JWTs and API keys. Developed by Next Era Solutions.
#[authentication]: Validates access tokens using the Authorization header.#[refresh_authentication]: Validates refresh tokens using the Authorization header.#[x_api_key]: Validates requests using the X-API-Key header.Authorization: Bearer <token>.ACCESS_TOKEN_SECRETREFRESH_TOKEN_SECRETJWT_AUDIENCEnextera_utils::jwt::validate_jwt() for validation.HttpRequest into your handler function.Supports localization based on Content-Language header:
en (default)zh-CNthmmuse actix_web::{get, web, App, HttpResponse, HttpServer, Responder};
use nextera_jwt::{authentication, refresh_authentication, x_api_key};
#[authentication]
async fn auth() -> impl Responder {
HttpResponse::Ok().body("Valid Token")
}
#[refresh_authentication]
async fn refresh_auth() -> impl Responder {
HttpResponse::Ok().body("Valid Refresh Token")
}
#[x_api_key]
async fn x_api_key() -> impl Responder {
HttpResponse::Ok().body("Valid X API Key")
}
| Variable | Purpose |
|---|---|
ACCESS_TOKEN_SECRET |
Secret for validating access JWT |
REFRESH_TOKEN_SECRET |
Secret for validating refresh JWT |
JWT_AUDIENCE |
Audience claim for validation |
X_API_KEY |
API key expected in header |
unwrap_or and expect(); improve error handling for production.HttpRequest as first argument in handler.nextera_utils crate.MIT License ยฉ 2025 Next Era Solutions