-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Add capabilities service #28168
UI: Add capabilities service #28168
Conversation
CI Results: |
Build Results: |
|
||
import type StoreService from 'vault/services/store'; | ||
|
||
export default class CapabilitiesService extends Service { |
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.
could also call this @permissions
if we're worried about confusing it with the @lazyCapabilities
method
ui/lib/core/addon/helpers/await.js
Outdated
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.
move this to addon so in templates we can do things like
{{#if (await (this.capabilities.canRead "secret/data/my-secret"))}}
Show something...
{{/if}}
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.
Good idea! Would love some sort of README about this, if nothing else than to establish that this is the newest pattern and we're moving away from capabilities on models.
A couple other improvements we could make here are caching (so we don't re-fetch the API for paths we already have) and passing multiple paths in the same capabilities call. This would be an especially useful improvement in places like KV, where there are multiple paths to check for the backend.
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.
preliminary comments!
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.
Very nice! 🚀
This reverts commit 3fdafc7.
…e/1.17.x (#28375) * backport of commit 49b46ea * add capabilities service (from #28168) * fix failing ent test --------- Co-authored-by: claire bontempo <[email protected]> Co-authored-by: Chelsea Shaw <[email protected]>
Description
Since we're moving away from checking capabilities in the ember data model, this adds a new
capabilities
service so permissions checks can happen more readily anywhere in the codebase.✅ enterprise test
sample implementation
TODO only if you're a HashiCorp employee
to N, N-1, and N-2, using the
backport/ent/x.x.x+ent
labels. If this PR is in the CE repo, you should only backport to N, using thebackport/x.x.x
label, not the enterprise labels.of a public function, even if that change is in a CE file, double check that
applying the patch for this PR to the ENT repo and running tests doesn't
break any tests. Sometimes ENT only tests rely on public functions in CE
files.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.