-
Notifications
You must be signed in to change notification settings - Fork 4.6k
UI: Show correct nav items when in chroot namespace #24492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c7a224f
Add sanitizeStart helper and tests
hashishaw 033c168
Update permission service to handle chroot_namespace; reorganize and …
hashishaw 721ae85
hide nav items for root namespace only when in chroot
hashishaw c60ebd7
chroot nav test coverage
hashishaw bd96b13
fix test
hashishaw 93d0040
Add changelog
hashishaw 0b4424b
Merge branch 'main' into ui/VAULT-22635/chroot-permissions
hashishaw 8526482
Merge branch 'main' into ui/VAULT-22635/chroot-permissions
hashishaw d77e9ac
Merge branch 'main' into ui/VAULT-22635/chroot-permissions
hashishaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ```release-note:bug | ||
| ui: fix navigation items shown to user when chroot_namespace configured | ||
| ``` |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| */ | ||
|
|
||
| import Service, { inject as service } from '@ember/service'; | ||
| import { sanitizePath, sanitizeStart } from 'core/utils/sanitize-path'; | ||
| import { task } from 'ember-concurrency'; | ||
|
|
||
| const API_PATHS = { | ||
|
|
@@ -65,6 +66,7 @@ export default Service.extend({ | |
| globPaths: null, | ||
| canViewAll: null, | ||
| readFailed: false, | ||
| chrootNamespace: null, | ||
| store: service(), | ||
| auth: service(), | ||
| namespace: service(), | ||
|
|
@@ -89,6 +91,7 @@ export default Service.extend({ | |
| this.set('exactPaths', resp.data.exact_paths); | ||
| this.set('globPaths', resp.data.glob_paths); | ||
| this.set('canViewAll', resp.data.root); | ||
| this.set('chrootNamespace', resp.data.chroot_namespace); | ||
| this.set('readFailed', false); | ||
| }, | ||
|
|
||
|
|
@@ -97,6 +100,7 @@ export default Service.extend({ | |
| this.set('globPaths', null); | ||
| this.set('canViewAll', null); | ||
| this.set('readFailed', false); | ||
| this.set('chrootNamespace', null); | ||
| }, | ||
|
|
||
| hasNavPermission(navItem, routeParams, requireAll) { | ||
|
|
@@ -124,20 +128,21 @@ export default Service.extend({ | |
| }, | ||
|
|
||
| pathNameWithNamespace(pathName) { | ||
| const namespace = this.namespace.path; | ||
| const namespace = this.chrootNamespace | ||
| ? `${sanitizePath(this.chrootNamespace)}/${sanitizePath(this.namespace.path)}` | ||
| : sanitizePath(this.namespace.path); | ||
| if (namespace) { | ||
| return `${namespace}/${pathName}`; | ||
| return `${sanitizePath(namespace)}/${sanitizeStart(pathName)}`; | ||
| } else { | ||
| return pathName; | ||
| } | ||
| }, | ||
|
|
||
| hasPermission(pathName, capabilities = [null]) { | ||
| const path = this.pathNameWithNamespace(pathName); | ||
|
|
||
| if (this.canViewAll) { | ||
| return true; | ||
| } | ||
| const path = this.pathNameWithNamespace(pathName); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this so we get a little better efficiency, skipping the method if |
||
|
|
||
| return capabilities.every( | ||
| (capability) => | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty for the comment!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still getting up to speed with the
chrootsituation - does true "root" meanrootroot?Does
this.currentCluster.hasChrootNamespacemean the user has a configured root namespace and so they will not haverootas the base/parent namespace? So therefore configuringchrootand havingrootas a namespace are mutually exclusive?Just looking for clarification so I understand 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasChrootNamespacemeans the Vault operator has setchroot_namespaceto some value on the config of the given listener, and so the user does not have access to "true root" (which yes, isrootnamespace). So, even if the UI is in its top-most namespace, ifchroot_namespaceis configured it is not the true root.Does that answer your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I think so - I wanted to clarify that setting the
chroot_namespacemeans that you are configuring the top namespace and so thereforerootwill NOT be a possible/accessible.Thank you!