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: Implement read-only KV/Session and Intention views based on ACLs #9706

Merged
merged 17 commits into from
Feb 18, 2021

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented Feb 4, 2021

This PR is a continuation of #9687.

Here we implement read-only views for KVs, Sessions and Intentions based on your ACL Tokens policies.

This means you can assign ACLs to users in the UI giving certain users read only access to areas like KV. This is currently at a global level using something like:

key_prefix "" {
  policy = "read"
}

which would give the user with a token with the above policy read only access to all KVs.

Being able to configure this more finely per KV will be added in a further PR.

Further notes:

  1. {{disabled}} modifier f0cc8cb. <fieldset>s have a nice feature that lets you set a <fieldset disabled> on them which means all of the form elements within the fieldset are in a disabled state, meaning you only have to set the disabled-ness in one place. The downside is, if you want everything disabled apart from one form element, there doesn't seem to be a native way to do that. Using a modifier instead means we can add the functionality we want here. This is currently not super reactive (if you add further elements to the parent element after insertion these will not be set to the correct value for disabled). In order to improve this we'll probably require some MutationObserver work. As and when we need that we can look at that then.
  2. Global configuration of protected routes 66c8cc9 and e66c220. We currently have a JSON-like object which is then used by Router in order to create embers routes. This means we can also use this information for other things, for example knowing whether a route is a wildcard route in order to add further url de/encoding logic to the params for this route. These commits further add to this configuration with an abilities: [] property. The abilities property allows you to use ember-cans DSL to specify what abilities a user requires in order to access a route. If the user doesn't have all of the specified abilities then they see a 403 page instead. Using the central configuration means we can add the logic required for this to our Consul specific base Route, then its super simple to see all in one place, what routes have additional ability based restrictions.
  3. Acceptance tests where added, along with a new step to allow us to set a users permissions during testing. Worthwhile noting that in order to set permissions during development the cookie names to use in WebInspector takes the form CONSUL_RESOURCE_{singular-resource-name}_{access_type}, so for example setting the cookie CONSUL_RESOURCE_INTENTION_WRITE=false will give you readonly intentions.

John Cowen added 9 commits February 4, 2021 17:07
In that you can set it to false on a parent node and all its sub nodes
will be disabled. It has an added improvement that you can then separate
allow children if you want to disable everything apart from one thing.

One caveat here is that it relies on dom twiddling and is therefore
disabling a parent is not currently very reactive and will need some
MutationObserver work to make it fully reactive.
@johncowen johncowen added the theme/ui Anything related to the UI label Feb 4, 2021
Copy link
Contributor

@kaxcode kaxcode left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@johncowen johncowen merged commit 547b266 into ui/feature/permissions Feb 18, 2021
@johncowen johncowen deleted the ui/feature/permissions-2 branch February 18, 2021 18:27
johncowen added a commit that referenced this pull request Feb 19, 2021
…9706)

* Adds a {{disabled}} modifier that works similar to fieldset

In that you can set it to false on a parent node and all its sub nodes
will be disabled. It has an added improvement that you can then separate
allow children if you want to disable everything apart from one thing.

One caveat here is that it relies on dom twiddling and is therefore
disabling a parent is not currently very reactive and will need some
MutationObserver work to make it fully reactive.

* Reorganize the base ability for reuse and add canWrite

* Add a session ability

* Make the mock-api authorize endpoint less brittle and more configurable

* Tweak intention write ability to include IsEditable

* Add authzing beforeModel hook to let us to configure auth 403s centrally

* Centrally configure abilities for allowing certain endpoints

* Add session inspection and allow easy access of can from permissions

* Implement read/write access based views across KV/Sessions + Intentions

* Show notification depending on item.Session

* Lint

* Only look at path when auto creating nspaced routes

* Conditionally show view or edit words based on permissions

* Add new step so we can control permissions from acceptance tests

* Add tests to assert permissions inspection functionality

* Lint

* Add CONSUL_RESOURCE_*_* to README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants