Skip to content

Commit

Permalink
ARSN-390: Add scuba arn for policy
Browse files Browse the repository at this point in the history
Relates to SCUBA-76 and SCUBA-77
  • Loading branch information
BourgoisMickael committed Jan 26, 2024
1 parent 29f39ab commit bfc8dee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/policyEvaluator/RequestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ function _findAction(service: string, method: string) {
return actionMapSTS[method];
case 'metadata':
return actionMapMetadata[method];
case 'scuba':
// currently only method is GetMetrics
return `scuba:${method}`;
default:
return undefined;
}
Expand Down Expand Up @@ -105,6 +108,10 @@ function _buildArn(
return `arn:scality:metadata::${requesterInfo!.accountid}:` +
`${generalResource}/`;
}
case 'scuba': {
return `arn:scality:scuba::${requesterInfo!.accountid}:` +
`${generalResource}/${specificResource || ''}`
}
default:
return undefined;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/policyEvaluator/utils/checkArnMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ export default function checkArnMatch(
const requestSegment = caseSensitive ? requestArnArr[j] :
requestArnArr[j].toLowerCase();
const policyArnArr = policyArn.split(':');
// We want to allow an empty account ID for utapi service ARNs to not
// We want to allow an empty account ID for utapi and scuba service ARNs to not
// break compatibility.
if (j === 4 && policyArnArr[2] === 'utapi' && policyArnArr[4] === '') {
const allowedEmptyAccountId = ['utapi', 'scuba'];
if (j === 4 && allowedEmptyAccountId.includes(policyArnArr[2]) && policyArnArr[4] === '') {
continue;
} else if (!segmentRegEx.test(requestSegment)) {
return false;
Expand Down

0 comments on commit bfc8dee

Please sign in to comment.