Admin tools for Claude: an MCP server, connected with an admin's approval
- services/mcp: the MCP server at /mcp (Streamable HTTP, stateless): the admin's reading tools, the daily tasks and the forum's moderation; every tool calls the site's API with the caller's token, and members' e-mail addresses and names are masked in the answers. - Backend: OAuth 2.1 for MCP clients (registration with Claude's or a local return address only, PKCE, rotating refresh tokens, revocation); the admin guards accept the token for reading and the writes in MCP_WRITES only. - Forum: an admin's token reaches the moderator endpoints only. - Frontend: the approval page (/oauth/engedely), Admin → Claude to revoke a connection, the authorization server's metadata at its standard address. - Deploy: the mcp service in compose, Caddy, CI; the worker removes old codes, tokens and clients. docs/mcp.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -509,6 +509,7 @@ async fn social_login(
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query("DELETE FROM sessions WHERE user_id = $1").bind(id).execute(&mut *tx).await?;
|
||||
db::revoke_oauth_grants(&mut *tx, id).await?;
|
||||
tracing::warn!(user = %id, provider, "unconfirmed password account taken over by its address's owner");
|
||||
}
|
||||
// The provider has verified the address, so it counts as verified here too.
|
||||
@@ -595,6 +596,8 @@ pub async fn logout(State(state): St, auth: AuthUser, jar: CookieJar) -> ApiResu
|
||||
/// Ends every session of the user (all devices).
|
||||
pub async fn logout_all(State(state): St, auth: AuthUser, jar: CookieJar) -> ApiResult<impl IntoResponse> {
|
||||
sqlx::query("DELETE FROM sessions WHERE user_id = $1").bind(auth.id()).execute(&state.db).await?;
|
||||
// The MCP clients connected by the user too (docs/mcp.md).
|
||||
db::revoke_oauth_grants(&state.db, auth.id()).await?;
|
||||
Ok((StatusCode::NO_CONTENT, jar.add(removal_cookie(&state.config))))
|
||||
}
|
||||
|
||||
@@ -659,6 +662,7 @@ pub async fn set_password_with_link(
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query("DELETE FROM sessions WHERE user_id = $1").bind(user_id).execute(&mut *tx).await?;
|
||||
db::revoke_oauth_grants(&mut *tx, user_id).await?;
|
||||
let mut user = load_user(&mut tx, user_id).await?;
|
||||
apply_bootstrap_admin(&state, &mut tx, &mut user).await?;
|
||||
tx.commit().await?;
|
||||
|
||||
Reference in New Issue
Block a user