| Crates.io | authorization-bridge |
| lib.rs | authorization-bridge |
| version | 0.2.2 |
| created_at | 2025-11-06 17:08:48.166309+00 |
| updated_at | 2025-11-14 19:26:55.59912+00 |
| description | An Actix Web middleware for authenticating HTTP requests through a remote API. It validates Authorization headers or cookies and attaches user info to requests. |
| homepage | https://github.com/SetliteWeb/authorization-middleware |
| repository | https://github.com/SetliteWeb/authorization-middleware |
| max_upload_size | |
| id | 1920019 |
| size | 69,399 |
Create a simple README.md:
An Actix Web middleware for authenticating requests using a remote API.
use actix_web::{App, HttpServer, HttpResponse, web};
use auth_middleware::AuthMiddleware;
async fn index() -> HttpResponse {
HttpResponse::Ok().body("Welcome to protected route!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.wrap(AuthMiddleware::new(
vec!["/public".to_string(), "/pub_api/".to_string()], // cover both
vec![Method::GET, Method::POST, Method::OPTIONS], // allow POST for uploads
))
.route("/", web::get().to(index))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
๐ง Environment
Set AUTH_API_URL to your authentication service endpoint:
AUTH_API_URL=http://localhost:8080/api/profile
๐ License
MIT
---
## โ๏ธ 5. `LICENSE`
Use MIT (common for Rust libraries):
```text
MIT License
Copyright (c) 2025 David Macharia
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
๐ง 6. Initialize Git
cd auth_middleware
git init
git add .
git commit -m "Initial commit: Auth middleware for Actix Web"
๐ 7. Test locally
Before publishing, run:
cargo check
cargo test
cargo doc --open
๐ชถ 8. Publish to crates.io
Log in with your GitHub account:
cargo login
(Youโll get your API token from https://crates.io/me
)
Publish the crate:
cargo publish
Thatโs it! ๐
Your middleware will now be live on crates.io and installable via:
[dependencies]
auth_middleware = "0.1"
Would you like me to add a test example showing how another crate can mock a request and check that the middleware inserts the user properly?