feat: access console with a permission tree, grouped grants and effective access
Some checks failed
ci / rust (push) Has been cancelled
ci / supply-chain (push) Has been cancelled
ci / web (push) Has been cancelled

Backend: grants accept a list of permissions; PUT /access/grants edits or renews a set atomically; refusals carry a reason; the grant list includes refresh grants per relation and the administrator-only permissions; users keep their last groups and admin flag; the emergency operator cannot hold grants.

Frontend: the Access screen shows the grantable permissions as a checkbox tree with dependencies, rows grouped by person or group, orbit and end date, expiry and no-effect states, and what each person can do right now.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 20:20:25 +07:00
parent 3bd0a1c9a3
commit c938afe1b5
15 changed files with 1412 additions and 223 deletions

View File

@@ -63,6 +63,10 @@ pub(super) fn migrate(conn: &Connection) -> Result<()> {
// Added after the first M2 build; default 0 keeps old rows without admin rights.
super::ensure_column(conn, "sessions", "admin", "INTEGER NOT NULL DEFAULT 0")?;
super::ensure_column(conn, "sessions", "groups", "TEXT NOT NULL DEFAULT '[]'")?;
// What the identity provider said at the user's last sign-in, kept after the session ends so the
// access screens can still say who is an administrator and which groups a person comes through.
super::ensure_column(conn, "users", "last_groups", "TEXT NOT NULL DEFAULT '[]'")?;
super::ensure_column(conn, "users", "last_admin", "INTEGER NOT NULL DEFAULT 0")?;
Ok(())
}
@@ -112,6 +116,12 @@ impl Db {
SELECT ?1, id, generation, ?3, ?4, ?5, ?5, ?5, ?6, ?7, ?8 FROM users WHERE id=?2 AND active=1",
params![session_digest(id), user_id, auth_method, credential_fp, now, now + ABSOLUTE_SECS, admin, serde_json::to_string(groups)?],
)?;
if inserted == 1 {
conn.execute(
"UPDATE users SET last_groups=?2, last_admin=?3 WHERE id=?1",
params![user_id, serde_json::to_string(groups)?, admin],
)?;
}
Ok(inserted == 1)
}