1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-19 00:15:43 +01:00

fix: connect environment with access service

This commit is contained in:
Fredrik Oseberg 2021-12-01 14:36:08 +01:00 committed by Ivar Conradi Østhus
parent 73d270d11f
commit d8ab79f71c
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
2 changed files with 14 additions and 3 deletions

View File

@ -14,6 +14,7 @@ interface PermissionChecker {
user: User,
permission: string,
projectId?: string,
environment?: string,
): Promise<boolean>;
}
@ -44,7 +45,7 @@ const rbacMiddleware = (
}
// For /api/admin/projects/:projectId we will find it as part of params
let { projectId } = params;
let { projectId, environment } = params;
// Temporary workaround to figure out projectId for feature toggle updates.
// will be removed in Unleash v5.0
@ -55,7 +56,12 @@ const rbacMiddleware = (
projectId = req.body.project || 'default';
}
return accessService.hasPermission(user, permission, projectId);
return accessService.hasPermission(
user,
permission,
projectId,
environment,
);
};
return next();
};

View File

@ -8,6 +8,7 @@ import { Logger } from '../../../logger';
import {
CREATE_FEATURE,
DELETE_FEATURE,
CREATE_FEATURE_STRATEGY,
UPDATE_FEATURE,
} from '../../../types/permissions';
import {
@ -75,7 +76,11 @@ export default class ProjectFeaturesController extends Controller {
// activation strategies
this.get(`${PATH_STRATEGIES}`, this.getStrategies);
this.post(`${PATH_STRATEGIES}`, this.addStrategy, UPDATE_FEATURE);
this.post(
`${PATH_STRATEGIES}`,
this.addStrategy,
CREATE_FEATURE_STRATEGY,
);
this.get(`${PATH_STRATEGY}`, this.getStrategy);
this.put(`${PATH_STRATEGY}`, this.updateStrategy, UPDATE_FEATURE);
this.patch(`${PATH_STRATEGY}`, this.patchStrategy, UPDATE_FEATURE);