`DELETE /v1/auth/session` — Invalidate a session handle. ```text DELETE /v1/auth/session Authorization: Bearer X-Session-Id: nds_... ``` The caller must present a valid bearer token. A session handle may only be invalidated by the authenticated caller — the identity is verified before any session state is read or mutated.
(
ConnectInfo(peer): ConnectInfo<SocketAddr>,
headers: HeaderMap,
State(state): State<AppState>,
)
| 63 | /// invalidated by the authenticated caller — the identity is verified before |
| 64 | /// any session state is read or mutated. |
| 65 | pub async fn delete_session( |
| 66 | ConnectInfo(peer): ConnectInfo<SocketAddr>, |
| 67 | headers: HeaderMap, |
| 68 | State(state): State<AppState>, |
| 69 | ) -> Result<impl IntoResponse, ApiError> { |
| 70 | // Auth check must come first — return 401/403 before touching session state. |
| 71 | let _identity = { |
| 72 | let peer_str = peer.to_string(); |
| 73 | crate::control::server::http::auth::resolve_identity(&headers, &state, &peer_str)? |
| 74 | }; |
| 75 | |
| 76 | let handle = headers |
| 77 | .get("x-session-id") |
| 78 | .and_then(|v| v.to_str().ok()) |
| 79 | .ok_or_else(|| ApiError::BadRequest("missing X-Session-Id header".into()))?; |
| 80 | |
| 81 | let found = state.shared.session_handles.invalidate(handle); |
| 82 | if !found { |
| 83 | return Err(ApiError::BadRequest("session handle not found".into())); |
| 84 | } |
| 85 | |
| 86 | Ok(axum::Json(HttpStatusOk::ok())) |
| 87 | } |
nothing calls this directly
no test coverage detected