-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change ability to check capabilities, not policy
The API change in #6017 returns JSON that contains the expanded policy, including all capabilities implied by a policy. So even if you set `policy="write"`, you get back a list of capabilities that includes `submit-job`. There’s therefore no reason to examine the returned policy.
- Loading branch information
Showing
3 changed files
with
18 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,13 +40,8 @@ export default Ability.extend({ | |
'[email protected]', | ||
function() { | ||
return this.rulesForActiveNamespace.some(rules => { | ||
// TODO given that the API returns a fully-expanded set of rules, | ||
// where just a policy word turns into an array of capabilities, | ||
// maybe checking capabilities is the only necessity? | ||
const policy = rules.Policy; | ||
const capabilities = getWithDefault(rules, 'Capabilities', []); | ||
|
||
return policy == 'write' || capabilities.includes('submit-job'); | ||
return capabilities.includes('submit-job'); | ||
}); | ||
} | ||
), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters