Skip to content

Commit

Permalink
fix: fix filter and update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-KumarH committed Oct 10, 2023
1 parent cf9c171 commit 821d163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/core/accessController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class AccessController {
if (rules.size == 0 && !!policy.effect) {
policyEffects.push({ effect: policy.effect, evaluation_cacheable: policy.evaluation_cacheable });
}

else {
let evaluationCacheableRule = true;
for (let [, rule] of policy.combinables) {
Expand Down Expand Up @@ -216,10 +215,9 @@ export class AccessController {
}

request.context = context || request.context;
console.log('Validating the Condition.......', rule.condition);
console.log('Req Target resources are...', JSON.stringify(request.target.resources));
this.logger.debug('Validating rule condition', { name: rule.name, condition: rule.condition });
matches = conditionMatches(rule.condition, request);
console.log('Matches result is..', matches);
this.logger.debug('condition validation response', { matches });
}
} catch (err) {
this.logger.error('Caught an exception while applying rule condition to request', { code: err.code, message: err.message, stack: err.stack });
Expand Down Expand Up @@ -628,13 +626,16 @@ export class AccessController {
operation: AccessControlOperation = 'isAllowed', maskPropertyList: Attribute[],
effect: Effect = Effect.PERMIT, regexMatch?: boolean): Promise<boolean> {
const requestTarget = request.target;
const resourceMatch = this.resourceAttributesMatch(ruleTarget.resources,
requestTarget.resources, operation, maskPropertyList, effect, regexMatch);
if (!resourceMatch) {
return false;
}
const subMatch = await this.checkSubjectMatches(ruleTarget.subjects, requestTarget.subjects, request);
const match = subMatch && this.attributesMatch(ruleTarget.actions, requestTarget.actions);
if (!match) {
if(!subMatch) {
return false;
}
return this.resourceAttributesMatch(ruleTarget.resources,
requestTarget.resources, operation, maskPropertyList, effect, regexMatch);
return subMatch && this.attributesMatch(ruleTarget.actions, requestTarget.actions);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/resourceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const marshallResource = (resource: any, resourceName: string): any => {

const makeFilter = (ids: string[]): any => {
return [{
filter: [{
filters: [{
field: 'id',
operation: FilterOperation.in,
value: ids
Expand Down

0 comments on commit 821d163

Please sign in to comment.