| Crates.io | axum-negotiate-layer |
| lib.rs | axum-negotiate-layer |
| version | 0.2.0 |
| created_at | 2024-12-19 22:50:48.572119+00 |
| updated_at | 2025-01-02 03:31:37.892622+00 |
| description | Negotiate HTTP layer library for axum. |
| homepage | |
| repository | https://github.com/2ndDerivative/axum-negotiate-layer |
| max_upload_size | |
| id | 1489647 |
| size | 17,371 |
This crate provides an axum-compatible tower service and layer to authenticate
connections using the Microsoft "HTTP Negotiate" protocol.
use axum::{routing::get, Extension, Router};
use axum_negotiate_layer::{Authenticated, NegotiateInfo, NegotiateLayer};
use tokio::net::TcpListener;
#[tokio::main]
async fn main() {
let router = Router::new()
.route("/", get(hello))
.layer(NegotiateLayer::new("HTTP/example.com"))
.into_make_service_with_connect_info::<NegotiateInfo>();
let listener = TcpListener::bind("0.0.0.0:80").await.unwrap().with_negotiate_info();
axum::serve(listener, router).await.unwrap();
}
async fn hello(Extension(a): Extension<Authenticated>) -> String {
format!("Hello, {}!", a.client().unwrap_or("whoever"))
}
This crate uses the cross-krb5 crate for Kerberos/Negotiate authentication.
I will take contributions as they come and will try to support this crate further along, depending on the needs of submissions. Feel free to ask for features or fixes!