Skip to content

Conversation

timricese
Copy link
Contributor

Fixes #3231

What changed?
When getting reconciled objects, instead of just looping over kinds and retrieving all objects cluster-wide, loop over only namespaces which the current user has access to, as well as kinds as before.

Why was this change made?
When an OIDC impersonated user does not have cluster-wide privileges, the weave-gitops UI will not show any resources that are reconciled as part of kustomize/helmrelease etc objects. This change means that only objects in namespaces which the user has permissions in will be listed.

How was this change implemented?
Simply providing another option to the client when calling List(), which specifies the namespace to list from, and looping over the namespaces which the user has access to. The list of user-accessible namespaces was already defined a few lines later in the code.

How did you validate the change?
Tested locally/in our production clusters.

We are expecting that existing tests should already cover this and dont need updating.

Release notes
Bugfix, nothing notable

Documentation Changes
None

@makkes makkes self-requested a review January 10, 2023 09:02
@makkes makkes self-assigned this Jan 10, 2023
@makkes makkes requested a review from a team January 10, 2023 09:02
@makkes makkes added bug Something isn't working area/ui Issues that require front-end work labels Jan 10, 2023
@opudrovs
Copy link
Contributor

@timricese thank you for submitting this PR! 🎉 We'll review it as soon as we have some bandwidth.

Some checks are failing. Could you please fix whatever can be fixed? (All that is not caused by some unpatched JS vulnerabilities or similar issues.)

@timricese
Copy link
Contributor Author

Thanks!

The failing test (just linting whitespace) should work now.

@makkes makkes force-pushed the list-by-namespace branch from 13b2ba7 to 9a0e781 Compare January 12, 2023 14:36
Tim Rice and others added 3 commits January 12, 2023 21:45
objects instead of getting from all namespaces
Adding tests for the different behaviour of the function based on user
permissions required reworking how the gRPC server is setup for
testing: Instead of having a single static user that's used for all
requests to the server now each requests needs to provide the user to
be impersonated in the context. This facilitates sophisticated
permission tests uncovering potential issues such as the one fixed by
this PR.
@makkes makkes force-pushed the list-by-namespace branch from 38af8b7 to 3f9ddbb Compare January 12, 2023 20:46
@makkes
Copy link
Member

makkes commented Jan 12, 2023

Great stuff @timricese. I added a commit providing integration tests for the intended behaviour. Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui Issues that require front-end work bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to see resources created by HelmReleases/Kustomizations
3 participants