Skip to content

Commit

Permalink
Modify variable access permissions for UI users with write in only ce…
Browse files Browse the repository at this point in the history
…rtain namespaces
  • Loading branch information
philrenaud committed Sep 26, 2024
1 parent c1127db commit ac78fcd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .changelog/24073.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixes an issue where variables paths would not let namespaced users write variables unless they also had * namespace variable write permissions
```
27 changes: 17 additions & 10 deletions ui/app/abilities/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,29 @@ export default class Variable extends AbstractAbility {

@computed('allPaths', 'namespace', 'path', 'token.selfTokenPolicies')
get policiesSupportVariableWriting() {
if (this.namespace === WILDCARD_GLOB && this.path === WILDCARD_GLOB) {
// If you're checking if you can write from root, and you don't specify a namespace,
// Then if you can write in ANY path in ANY namespace, you can get to /new.
if (this.path === WILDCARD_GLOB) {
// If checking for write permission on the root path
return this.policyNamespacesIncludeVariablesCapabilities(
this.token.selfTokenPolicies,
['write'],
this._nearestMatchingPath(this.path)
WILDCARD_GLOB
);
} else {
// Checking a specific path in a specific namespace.
// TODO: This doesn't cover the case when you're checking for the * namespace at a specific path.
// Right now we require you to specify yournamespace to enable the button.
// Checking a specific path
const matchingPath = this._nearestMatchingPath(this.path);
return this.allPaths
.find((path) => path.name === matchingPath)
?.capabilities?.includes('write');
if (this.namespace === WILDCARD_GLOB) {
// Checking for the * namespace at a specific path
return this.policyNamespacesIncludeVariablesCapabilities(
this.token.selfTokenPolicies,
['write'],
matchingPath
);
} else {
// Checking a specific path in a specific namespace
return this.allPaths
.find((path) => path.name === matchingPath)
?.capabilities?.includes('write');
}
}
}

Expand Down

0 comments on commit ac78fcd

Please sign in to comment.