Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions forge/routes/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ async function init (app, opts) {
reply.code(401).send({ code: 'unauthorized', error: 'unauthorized' })
return
}
if (accessToken.ownerType === 'user:expert-mcp') {
// The expert MCP token is short-lived (5 min TTL) and first-party only.
// It inherits the user's full permissions rather than being restricted
// to a hardcoded allowlist. HITL and RBAC provide the access control.
delete request.session.scope
}
resolveSourceContext(request)
return
}
Expand Down
31 changes: 0 additions & 31 deletions forge/routes/auth/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,6 @@ const IMPLICIT_TOKEN_SCOPES = {
'broker:clients:list',
'broker:clients:link',
'assistant:call' // permit access to assistant
],
'user:expert-mcp': [
// applications
'team:projects:list', // list applications, list hosted instances, get instances status
'project:read', // get application details
'team:device:list', // list application remote instances
'application:audit-log', // get application audit log
// devices
'device:read', // get remote instance details
'device:create', // create remote instance
'device:edit', // assign remote instance to application
// hosted instances
'project:create', // create application, create hosted instance, check instance name
'project-type:read',
'project-type:list',
'project:log', // get hosted instance logs
// snapshots
'project:snapshot:list', // list hosted instance snapshots
'project:snapshot:create', // create hosted instance snapshot
'device:snapshot:list', // list remote instance snapshots
'device:snapshot:create', // create remote instance snapshot
// teams
'user:team:list', // list teams
'team:read', // get team details
// tables
'team:database:list', // list/get databases, list/get tables, query table data
// platform
'stack:list',
'flow-blueprint:list',
'project:status',
'template:list'
]
}

Expand Down
15 changes: 9 additions & 6 deletions test/unit/forge/routes/auth/permissions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ describe('Permissions API', async () => {
}

}
// Dedicated platform-automation token: ownerType 'user:expert-mcp' + ff-expert:platform scope
// Dedicated platform-automation token: ownerType 'user:expert-mcp', scope cleared
// at auth time so the token inherits the user's full permissions (gated by team role)
const EXPERT_PLATFORM_TOKEN_TEAM_MEMBER = {
session: { User: { id: 'u123' }, ownerType: 'user:expert-mcp', scope: ['ff-expert:platform'] },
session: { User: { id: 'u123' }, ownerType: 'user:expert-mcp' },
teamMembership: { role: Roles.Member }
}
const EXPERT_PLATFORM_TOKEN_TEAM_OWNER = {
session: { User: { id: 'u123' }, ownerType: 'user:expert-mcp', scope: ['ff-expert:platform'] },
session: { User: { id: 'u123' }, ownerType: 'user:expert-mcp' },
teamMembership: { role: Roles.Owner }
}
// A plain user token must not gain broad access by carrying the platform scope
Expand Down Expand Up @@ -239,12 +240,14 @@ describe('Permissions API', async () => {
})

describe('expert platform token', () => {
it('Allows access to implicit scopes', async () => {
it('Inherits user permissions based on team role', async () => {
expectPass(await sendRequest('team:read', EXPERT_PLATFORM_TOKEN_TEAM_MEMBER))
})
it('Prevents access to scopes not in the implicit list', async () => {
it('Allows owner-level actions for an owner', async () => {
expectPass(await sendRequest('team:edit', EXPERT_PLATFORM_TOKEN_TEAM_OWNER))
})
it('Prevents member from accessing owner-level actions', async () => {
expectFail(await sendRequest('team:edit', EXPERT_PLATFORM_TOKEN_TEAM_MEMBER))
expectFail(await sendRequest('team:edit', EXPERT_PLATFORM_TOKEN_TEAM_OWNER))
})
it('Does not grant broad access to a plain user token carrying the scope', async () => {
expectFail(await sendRequest('team:read', USER_TOKEN_EXPERT_PLATFORM_SCOPE_TEAM_MEMBER))
Expand Down
Loading