Skip to content
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

UI: always send capabilities-self request in user's root namespace #24168

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

hashishaw
Copy link
Contributor

sys/capabilities-self is an endpoint the UI uses to surface actions that a user can take within the GUI. The endpoint is on the default policy so that users can by default use the UI in the intended way.

However, the policy is only applicable to the namespace where the user's auth mount is, so a user with the default policy only who logs into a child namespace that they have access to might see an error related to capabilities-self, or erroneously see buttons for actions they don't have capabilities to perform.

This PR fixes that experience by ensuring the capabilities-self endpoint is always queried on the user's root namespace, and adds the rest of the current namespace to the beginning of the queried path.

@hashishaw hashishaw added ui bug Used to indicate a potential bug backport/1.13.x labels Nov 16, 2023
@hashishaw hashishaw added this to the 1.13.11 milestone Nov 16, 2023
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Nov 16, 2023
* @param {string} rootPath eg apps/prod
* @returns the leftover segment, eg app_1/test
*/
export function getRelativePath(fullPath = '', rootPath = '') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had this logic within the namespace computed property, but it was much easier to test as a util

Copy link

Build Results:
All builds succeeded! ✅

Copy link
Contributor

@zofskeez zofskeez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the update.

ui/lib/core/addon/utils/sanitize-path.js Outdated Show resolved Hide resolved
@hashishaw hashishaw merged commit b833b30 into main Nov 20, 2023
69 checks passed
@hashishaw hashishaw deleted the VAULT-21375/capabilities-self-always-with-user-root branch November 20, 2023 19:21
hashishaw added a commit that referenced this pull request Nov 20, 2023
…24168)

* Add getRelativePath helper and use to calculate relativeNamespace

* Always request capabilities-self on users root ns and prefix body with relative path

* Update capabilities adapter with test

* add changelog

* Simplify getRelativePath logic

* test update
@hashishaw hashishaw modified the milestones: 1.13.11, 1.15.3 Nov 20, 2023
fopina-ci pushed a commit to fopina/vault that referenced this pull request Dec 1, 2023
…ashicorp#24168) (hashicorp#24204)

* Add getRelativePath helper and use to calculate relativeNamespace

* Always request capabilities-self on users root ns and prefix body with relative path

* Update capabilities adapter with test

* add changelog

* Simplify getRelativePath logic

* test update
@hellobontempo hellobontempo mentioned this pull request Aug 23, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants