Skip to content

Commit

Permalink
chore: restrict on RBAC middleware (#9000)
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonfournier authored Dec 19, 2024
1 parent de5f9be commit 3468161
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/lib/middleware/rbac-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function findParam(
}

const rbacMiddleware = (
config: Pick<IUnleashConfig, 'getLogger'>,
config: Pick<IUnleashConfig, 'getLogger' | 'isOss'>,
{
featureToggleStore,
segmentStore,
Expand Down Expand Up @@ -98,6 +98,24 @@ const rbacMiddleware = (
) {
projectId = 'default';
}
if (config.isOss) {
if (projectId !== undefined && projectId !== 'default') {
logger.error(
'OSS is only allowed to work with default project.',
);
return false;
}
const ossEnvs = ['default', 'development', 'production'];
if (
environment !== undefined &&
!ossEnvs.includes(environment)
) {
logger.error(
`OSS is only allowed to work with ${ossEnvs} environments.`,
);
return false;
}
}

// DELETE segment does not include information about the segment's project
// This is needed to check if the user has the right permissions on a project level
Expand Down

0 comments on commit 3468161

Please sign in to comment.