Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: restrict on RBAC middleware
Browse files Browse the repository at this point in the history
gastonfournier committed Dec 19, 2024
1 parent 29a2cc0 commit a118a90
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
@@ -33,7 +33,7 @@ export function findParam(
}

const rbacMiddleware = (
config: Pick<IUnleashConfig, 'getLogger'>,
config: Pick<IUnleashConfig, 'getLogger' | 'isOss'>,
{
featureToggleStore,
segmentStore,
@@ -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

0 comments on commit a118a90

Please sign in to comment.