Skip to content

Commit

Permalink
Fix RBAC permissions without subject ignoring conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Convly committed May 12, 2021
1 parent 43b947b commit 7fe9797
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/strapi-admin/services/permission/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
isFunction,
isBoolean,
isArray,
isNil,
isEmpty,
isObject,
prop,
Expand Down Expand Up @@ -160,7 +161,7 @@ module.exports = conditionProvider => {
await this.applyPermissionProcessors(permission);

// Extract the up-to-date components from the permission
const { action, subject = 'all', properties = {}, conditions } = permission;
const { action, subject, properties = {}, conditions } = permission;

// Register the permission if there is no condition
if (isEmpty(conditions)) {
Expand Down Expand Up @@ -239,7 +240,12 @@ module.exports = conditionProvider => {
const registerToCasl = caslPermission => {
const { action, subject, fields, condition } = caslPermission;

can(action, subject, fields, isObject(condition) ? condition : undefined);
can(
action,
isNil(subject) ? 'all' : subject,
fields,
isObject(condition) ? condition : undefined
);
};

const runWillRegisterHook = async caslPermission => {
Expand Down

0 comments on commit 7fe9797

Please sign in to comment.