Files
tkmind_go/crates/goose-server/src/auth.rs
T
Andrew Harvard 91a6b21f39 feat: add mcp app renderer (#6095)
Co-authored-by: Douwe Osinga <douwe@block.xyz>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-22 18:01:21 -05:00

29 lines
715 B
Rust

use axum::{
extract::{Request, State},
http::StatusCode,
middleware::Next,
response::Response,
};
pub async fn check_token(
State(state): State<String>,
request: Request,
next: Next,
) -> Result<Response, StatusCode> {
if request.uri().path() == "/status"
|| request.uri().path() == "/mcp-ui-proxy"
|| request.uri().path() == "/mcp-app-proxy"
{
return Ok(next.run(request).await);
}
let secret_key = request
.headers()
.get("X-Secret-Key")
.and_then(|value| value.to_str().ok());
match secret_key {
Some(key) if key == state => Ok(next.run(request).await),
_ => Err(StatusCode::UNAUTHORIZED),
}
}