mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-04 00:06:39 +00:00
feat: workspace role mcp access always starts from the instance's setting
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7cd4bb2729
commit
7a1cfefed0
@@ -12,6 +12,8 @@
|
||||
setting: McpRoleSetting | undefined
|
||||
/** The limit of the layer below, which an unset `setting` inherits. */
|
||||
instanceLimit?: McpRoleSetting
|
||||
/** The role is the instance's, overridden here: unset follows the instance's setting. */
|
||||
inherits?: boolean
|
||||
/** What the role allows; undefined while not known. */
|
||||
caps?: RoleCapabilities
|
||||
/** The workspace overriding the role. Without one the role is the instance's, which cannot
|
||||
@@ -26,6 +28,7 @@
|
||||
let {
|
||||
setting,
|
||||
instanceLimit,
|
||||
inherits = false,
|
||||
caps,
|
||||
workspace,
|
||||
frozen = false,
|
||||
@@ -48,8 +51,9 @@
|
||||
}
|
||||
|
||||
const effective = $derived(setting?.access ?? instanceLimit?.access ?? ROLE)
|
||||
// Without an instance limit, following the role is storing nothing.
|
||||
const selected = $derived(setting?.access ?? (instanceLimit ? INHERIT : ROLE))
|
||||
// Unset follows the layer below: the instance's setting, or the role itself.
|
||||
const unset = $derived(inherits ? INHERIT : ROLE)
|
||||
const selected = $derived(setting?.access ?? unset)
|
||||
|
||||
// Only what lowers the access: a role that cannot run already reads only, and gets nothing
|
||||
// from running tools. Read only stays, since workspace admins holding the role still run. A
|
||||
@@ -61,20 +65,21 @@
|
||||
|
||||
const items = $derived(
|
||||
[
|
||||
...(instanceLimit ? [INHERIT] : []),
|
||||
...(inherits ? [INHERIT] : []),
|
||||
ROLE,
|
||||
...(Object.keys(MCP_ROLE_LIMIT_LABELS) as Access[]).filter(
|
||||
(value) => value === setting?.access || (!frozen && lowers(value))
|
||||
)
|
||||
]
|
||||
// Frozen, a stored setting can only be removed.
|
||||
.filter(
|
||||
(value) => !frozen || value === selected || value === (instanceLimit ? INHERIT : ROLE)
|
||||
)
|
||||
.filter((value) => !frozen || value === selected || value === unset)
|
||||
.filter((value, i, all) => all.indexOf(value) === i)
|
||||
.map((value) => ({
|
||||
value,
|
||||
label: value === INHERIT ? inheritedLabel(instanceLimit!) : limitLabel(value as Access)
|
||||
label:
|
||||
value === INHERIT
|
||||
? inheritedLabel(instanceLimit ?? { access: ROLE })
|
||||
: limitLabel(value as Access)
|
||||
}))
|
||||
)
|
||||
|
||||
@@ -120,7 +125,8 @@
|
||||
function setAccess(value: string) {
|
||||
if (value === selected) return
|
||||
if (value === INHERIT) return onchange(undefined)
|
||||
if (value === ROLE) return onchange(instanceLimit ? { access: ROLE } : undefined)
|
||||
// Over an instance role, following the role is stored: it holds whatever the instance sets.
|
||||
if (value === ROLE) return onchange(inherits ? { access: ROLE } : undefined)
|
||||
onchange({ access: value as Access })
|
||||
}
|
||||
|
||||
|
||||
@@ -333,6 +333,7 @@
|
||||
? data.instance_mcp[name]
|
||||
: undefined}
|
||||
caps={runUnknown(name) ? undefined : caps}
|
||||
inherits={!!role}
|
||||
{workspace}
|
||||
frozen={!data?.custom_roles_enabled}
|
||||
onchange={(mcp) => setMcp(name, mcp)}
|
||||
|
||||
Reference in New Issue
Block a user