oauth2-test-server 0.2.2

A fast, fully configurable, in-memory OAuth 2.0 + OpenID Connect authorization server for testing, zero-HTTP mode and DCR support for testing auth flow in MCP Servers and MCP Clients
Documentation
use axum::{
    extract::{Form, State},
    http::StatusCode,
    response::IntoResponse,
    Json,
};
use serde_json::json;
use std::collections::HashMap;

use crate::store::AppState;

pub async fn revoke(
    State(state): State<AppState>,
    Form(form): Form<HashMap<String, String>>,
) -> impl IntoResponse {
    let token = form.get("token").cloned().unwrap_or_default();
    if let Some(mut t) = state.store.get_token(&token).await {
        t.revoked = true;
        state.store.update_token(&token, t).await;
    }
    if let Some(mut t) = state.store.get_refresh_token(&token).await {
        t.revoked = true;
        state.store.update_refresh_token(&token, t).await;
    }
    (StatusCode::OK, Json(json!({}))).into_response()
}