Add local password-TOTP sessions and scoped revocable MCP tokens

This commit is contained in:
2026-11-17 20:05:28 +01:00
parent 7fe20df34f
commit 9fa0fb81ff
17 changed files with 1804 additions and 27 deletions
+12 -3
View File
@@ -1015,7 +1015,7 @@ async fn authorize_http(
recheck(&mut tx, &plan).await?;
// Both requester and approver retain explicit operator rights: the only
// shipped dev principals are fixed-scope and cannot grant memberships.
if !requester_enabled(&state, &plan.principal, tenant) {
if !requester_enabled(&state, &mut tx, &plan.principal, tenant).await? {
return Err(fail("AUTHORIZATION_REVOKED"));
}
for job in &plan.jobs {
@@ -1058,8 +1058,17 @@ async fn authorize_http(
tx.commit().await?;
Ok(Json(operation(&state, &p, tenant, op).await?))
}
pub fn requester_enabled(state: &crate::State, name: &str, tenant: Uuid) -> bool {
state.auth.operator_enabled(name, tenant)
pub async fn requester_enabled(
state: &crate::State,
tx: &mut Transaction<'_, Postgres>,
name: &str,
tenant: Uuid,
) -> std::result::Result<bool, sqlx::Error> {
if name.starts_with("mcp:") {
crate::mcp_tokens::enabled_in(tx, name).await
} else {
Ok(state.auth.operator_enabled(name, tenant))
}
}
pub async fn operation(
state: &crate::State,