feat: grant a new plugin or connector to everyone by default — the admin's job is now removal, not distribution
Nightly Build / build (push) Successful in 7m23s

The grant junctions (plugin_access, mcp_global_access, mcp_catalog_access)
stay deny-by-default internally, but the rows are written for you at two
moments and never again:

  — an object is CREATED: PluginManager::update_config (first toggle —
    the plugins row's birth), mcp::catalog_upsert, marketplace install,
    mcp::global_enable
  — a user is CREATED: UserManager::register_user

Who is included is the role attrs.auto_grant flag (default true, so every
role predating the attribute behaves like an adult member). The seeded
Children preset sets it to false, which is the whole reason the attribute
exists. Admins are skipped because they hold everything implicitly. The
role editor now exposes the switch as a checkbox.

New crate module: db::access_defaults (seed_new_object, seed_new_user,
set_grant_by_default). Additive columns: grant_by_default on plugins,
mcp_catalog, mcp_global_servers (INTEGER NOT NULL DEFAULT 1).

On the frontend the Roles page gets a "New extensions" column and
checklist; the user's plugin/connector rosters are unchanged. i18n:
en, fr, it.

Docs: new docs/access.md for the assistant, plus index.md cross-link.
CLAUDE.md updated with a full default-access section.
This commit is contained in:
2026-07-29 15:53:51 +01:00
parent 0ed94225b2
commit e6818408cb
15 changed files with 700 additions and 19 deletions
+19
View File
@@ -38,6 +38,7 @@ use serde_json::{json, Value};
use sha2::{Digest, Sha256};
use tokio::sync::RwLock;
use skald_core::db::access_defaults;
use skald_core::db::{mcp_catalog, role_capabilities};
use skald_core::skald::Skald;
@@ -743,6 +744,10 @@ pub async fn install(
let icon_small_path = installed_icon(h.entry.icon_small.as_deref(), &folder, &installed);
let icon_large_path = installed_icon(h.entry.icon_large.as_deref(), &folder, &installed);
// An update or re-install keeps the audience the admin has curated since; only
// a first install applies the default one (`db::access_defaults`).
let is_new_entry = mcp_catalog::get_by_name(skald.db(), &h.entry.id).await?.is_none();
let id = mcp_catalog::upsert(
skald.db(),
mcp_catalog::UpsertCatalog {
@@ -795,6 +800,20 @@ pub async fn install(
)
.await?;
// Authorize the standard audience to activate it, so an installed connector is
// usable by the household without a second pass on the Users page. Best-effort
// and additive: a failure leaves grants to be set by hand, never withdraws one.
if is_new_entry {
match access_defaults::seed_new_object(
skald.db(),
access_defaults::Grantable::Catalog(&h.entry.id),
).await {
Ok(0) => {}
Ok(n) => tracing::info!(connector = %h.entry.id, users = n, "connector granted to auto-grant users"),
Err(e) => tracing::warn!(connector = %h.entry.id, error = %e, "default connector grants failed (non-fatal)"),
}
}
// Announce the (re)install so anything already running it catches up without
// waiting for each user's next login: enabled global servers re-snapshot the
// description and restart; each live user who activated it gets its files/deps