Skip to content

Commit

Permalink
fix: connect environment with access service
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrikOseberg authored and ivarconr committed Jan 11, 2022
1 parent 73d270d commit d8ab79f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/lib/middleware/rbac-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface PermissionChecker {
user: User,
permission: string,
projectId?: string,
environment?: string,
): Promise<boolean>;
}

Expand Down Expand Up @@ -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
Expand All @@ -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();
};
Expand Down
7 changes: 6 additions & 1 deletion src/lib/routes/admin-api/project/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Logger } from '../../../logger';
import {
CREATE_FEATURE,
DELETE_FEATURE,
CREATE_FEATURE_STRATEGY,
UPDATE_FEATURE,
} from '../../../types/permissions';
import {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d8ab79f

Please sign in to comment.