-
Notifications
You must be signed in to change notification settings - Fork 162
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
Show controls as read only based on tenant permissions #1472
Show controls as read only based on tenant permissions #1472
Conversation
@jakubp-eliatra , the DCO check is failing on this PR. I'm going to hold off on approving the CI run since we'll have to re-run anyway. |
81c311f
to
ab96df7
Compare
Just updated the PR. Two remarks:
Another possible solution, and maybe something to address either way in the future, would be to stop ignoring the capabilities route.
That way, the request will not throw an error if it is not authenticated, but if it is authenticated, the regular process would continue.
The new property is an array that contains the names of capabilities that will get toggled to false (for read only tenants) using the logic from this PR. So basically we would need to add this one line to each capabilities_provider.ts for all affected plugins. The plugins that need to be modified include:
PS. One idea that also came up was to make sure that all apps register capability 'showWriteControls', just as the Dashboards app does. That one capability would fit well for the read only use case, if it takes precedence over other capabilities that are used for write controls. But since we already had a discussed solution, we went that path. |
0a9a91d
to
df2bbaf
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1472 +/- ##
=======================================
Coverage 66.63% 66.63%
=======================================
Files 94 94
Lines 2395 2395
Branches 319 319
=======================================
Hits 1596 1596
Misses 728 728
Partials 71 71 ☔ View full report in Codecov by Sentry. |
We took our time to estimate the efforts of adjusting internal and external plugins to read only mode. Here are the results: a) internal plugins that need modification:
asterisk (*) - registers capabilities but doesn't do anything with them OR uses capabilities in a way unrelated with logic that should be updated for read only mode; they might need little adjustments or not at all, but they should at least be tested b) external plugins that need modification:
Those are the only two out of external plugins that we found they have something to do with capabilities at all. There doesn't seem to be any logic related with read only mode inside of those plugins. By that I mean that I checked the codebase in general, wandering from file to file and searched for buzzwords such as capabilities + readonly/disabled (obviously with excluding cases where it's just UI logic, such as disabling a form field somewhere). Due to the fact that for example maps plugin contains customizable layers of maps (and user can set zoom etc.), I believe it would be best for these two to incorporate some logic related with read only mode for those two plugins. In other words, a support for read only mode would make for a better UX in case of those plugins. c) my opinion on the research that's been done: Luckily, most of changes are limited to main Dashboards repo, however in the future more and more plugins might need to be aware of how the read only mode works and what property should be registered (hide_for_read_only array if that's what we're going with) to make it work properly. Therefore documentation updates should be & will be included in the read only PR. Summing up, it seems that there is no ideal solution. We either:
|
@jakubp-eliatra Are there any tests that can be written for this change? Unit, integration of functional tests? |
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.
Hi @jakubp-eliatra, thank you for putting this together. Overall, everything makes sense to me. That being said, we will want to add some tests to verify the functionality is expected. Since we are making a pretty significant UI change when the tenant is read-only, you should be able to use Cypress to check that an element which is present with not read-only is no longer present for a read-only tenant.
05b11be
to
4624c9b
Compare
Signed-off-by: Kajetan Nobel <k.nobel@routegroup.pl>
4624c9b
to
87d40fa
Compare
2af254e
to
c38d4cc
Compare
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.
Looks good, just one comment about an error message
Signed-off-by: Kajetan Nobel <k.nobel@routegroup.pl>
Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com>
@DarshitChanpura @cwperks Regarding unauthorized routes, I found that we've got a similar implementation here security-dashboards-plugin/server/auth/types/authentication_type.ts Lines 218 to 233 in 31c5a72
which already contains not exhaustive list. Maybe it would be good to refactor there and reuse here. There is also a possibility to use |
I agree. We should refactor to re-use.
i'm not sure about this one as this seems a change in design or the way API works. This could be done in a follow-up PR |
This would be my preferred approach. I think it would be better for maintenance to have an annotation/option where the route is declared that can signal whether the route is protected (auth required) or not. Most instances of routes not requiring auth are going to be login endpoints. |
…oc' into HEAD Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com>
@DarshitChanpura @cwperks I tried to base it on
I'm going rather to keep the current implementation and use there |
@DarshitChanpura @cwperks Basically while the |
Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com>
e70efb5
d902f1f
to
e70efb5
Compare
…board Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com>
@cwperks Regarding #1472 (comment) I've added a fix to it. |
Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com>
…plication in interface Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com>
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've reviewed the outstanding comments as well - thanks!
Signed-off-by: Kajetan Nobel <k.nobel@routegroup.pl> Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com> Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com> Co-authored-by: Peter Nied <peternied@hotmail.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit cfc83dd)
Signed-off-by: Kajetan Nobel <k.nobel@routegroup.pl> Signed-off-by: Kajetan Nobel <kajetan.nobel@eliatra.com> Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com> Co-authored-by: Peter Nied <peternied@hotmail.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit cfc83dd) Co-authored-by: jakubp-eliatra <126599757+jakubp-eliatra@users.noreply.github.com>
Description
Adds a proper read only mode support for read only tenants.
A new capability
hide_for_read_only
as array is utilized to recognize the capabilities which should be disable in read only mode. If a read only tenant is recognized the capabilities associated with writing access such as 'createNew' and 'saveQuery' are then set to false.Category.
New feature
Why these changes are required?
What is the old behavior before changes and new behavior after changes?
For example re-arranging visualisations is not possible in such mode now.