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

Package repository management UI for users with restricted permissions #5480

Merged
merged 7 commits into from
Oct 20, 2022

Conversation

castelblanque
Copy link
Collaborator

@castelblanque castelblanque commented Oct 18, 2022

Description of the change

This PR improves the repositories management screen for the cases of users with restricted permissions.
Before, there was a single disableControls flag for all repositories, regardless of the plugin.

Now this PR introduces a function PackageRepositoriesService.getRepositoriesPermissions that checks the permissions for repos CRDs per plugin. It does so by invoking multiple can-i requests, which could be improved by adding a new, on purpose, backend API.

This permissions check allows to enable/disable edit controls at the repo level and not globally as before.
For example, a user that:

  • Does not have permissions to global repos
  • Has read only permission to Helm repos in a namespace
  • Has update permission to Carvel repos in a namespace
  • Has no creation permissions for any repo type
    will see a screen like this:

image

Also, after #5453 and #5460, users with no cluster-wide permissions but with permissions in a specific ns, can see the repositories list without an alert error.

Benefits

  • Users will have a better feedback on the actions that they can do in UI when it comes to managing repositories

Possible drawbacks

N/A

Applicable issues

Rafa Castelblanque added 4 commits October 17, 2022 17:46
Signed-off-by: Rafa Castelblanque <[email protected]>
Signed-off-by: Rafa Castelblanque <[email protected]>
@netlify
Copy link

netlify bot commented Oct 18, 2022

Deploy Preview for kubeapps-dev canceled.

Name Link
🔨 Latest commit f25c619
🔍 Latest deploy log https://app.netlify.com/sites/kubeapps-dev/deploys/634ed601bb54320008b293e5

Rafa Castelblanque added 3 commits October 18, 2022 18:08
Signed-off-by: Rafa Castelblanque <[email protected]>
Signed-off-by: Rafa Castelblanque <[email protected]>
@ppbaena
Copy link
Collaborator

ppbaena commented Oct 19, 2022

Thanks for this enhancement to have better feedback from the UI according to your permission.

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

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

Woah, interesting change! Fine-grained permissions finally, excellent!

),
)
.filter(i => i !== undefined),
).then(results => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about using the await keyword instead like in other places?

also, we should have a .catch to handle any promise error, shouldn't we?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason to use Promise.all is to trigger an instance of .getRepositoriesPermissions per plugin, all three started at the same time.

What is being called underneath is a set of canI calls. There is a catch per canI invocation in getResourcePermissions, so we are handling the potential errors there.

setReposRBAC(rbac);
});

// Cluster-wide check
Kube.canI(cluster, "kubeapps.com", "apprepositories", "list", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to this PR, but just curious... what this canSetAllNS is for? It seems it's coupled with the helm plugin, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was a previously existing flag. It controls if the toggle to show repos from all namespaces is hidden.
image
Making this feature cross-plugin could be a task for the new UI #5515.

config: IConfig,
plugin: Plugin,
): IPackageRepositoryPermission | undefined => {
switch (plugin.name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the answer is no... but: can we obtain these strings from the plugin backend somehow? Like, what if packaging.carvel.dev get eventually renamed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a comment exactly about that a little bit below.
We could even add a new API endpoint to provide the permissions of the user for e.g. repos.
In this way the UI would not need to know anything about resource group, name, verb, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App Repository UI does not properly handle cases where the user does not have read/write to app repos in ns
4 participants