-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat: RBAC csv policy can be composed by multiple configmap keys #12511
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #12511 +/- ##
==========================================
+ Coverage 49.25% 49.28% +0.02%
==========================================
Files 251 251
Lines 43521 43541 +20
==========================================
+ Hits 21438 21458 +20
Misses 19949 19949
Partials 2134 2134
☔ View full report in Codecov by Sentry. |
util/rbac/rbac.go
Outdated
strBuilder.WriteString(p) | ||
} | ||
// append additional policies at the end of the csv | ||
csvRegex := regexp.MustCompile(fmt.Sprintf("^%s.+$", ConfigMapPolicyCSVKey)) |
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 would suggest to make the suffix for the entries explicit, and then use strings.HasSuffix(s, ".csv")
instead of a regexp matcher.
So what is now policy.csv.overlay1
would become policy.overlay1.csv
. At least to me, this would be more straight forward.
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.
That makes sense. I will make the change. To be safe I will make 2 checks:
strings.HasSuffix(s, ".csv") && strings.HasPrefix(s, "policy.")
WDYT?
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.
Pushed the changes. Can you please take another look?
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.
@jannfis ping :)
Hello, |
@JorTurFer Hopefully it will be available in the next release. |
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 got just something up for discussion
util/rbac/rbac.go
Outdated
strBuilder.WriteString(p) | ||
} | ||
// append additional policies at the end of the csv | ||
for key, value := range data { |
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.
One thought here: The order of keys in a map is non-deterministic afaik. Policy order may be important.
Would it make sense to:
- Handle entry for
policy.csv
specially (e.g. first to process) - Process the rest of the entries sorted by keys, not randomly/non-deterministic
?
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.
Handle entry for policy.csv specially (e.g. first to process)
This is already the case. See line 399-400
Process the rest of the entries sorted by keys, not randomly/non-deterministic
This is a good idea. Will update the code and let you know.
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.
This is already the case. See line 399-400
D'oh. I would blame it on not having had enough coffee, but that would be a lie. Stupid me :)
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.
No problem at all! :D
Updated the code. Please take a look.
Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.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.
LGTM!
…oproj#12511) * feat: RBAC csv policy can be composed by multiple configmap keys Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> * implement RBAC csv match by suffix and prefix Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> * add documentation Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> * add policies in deterministic order Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> --------- Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
…oproj#12511) * feat: RBAC csv policy can be composed by multiple configmap keys Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> * implement RBAC csv match by suffix and prefix Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> * add documentation Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> * add policies in deterministic order Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com> --------- Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
This PR adds support to provide multiple RBAC csv entries in
argocd-rbac-cm
.Example:
This is useful to allow composing RBAC policies with multiple Kustomize overlays.
fix #8324
Signed-off-by: Leonardo Luz Almeida leonardo_almeida@intuit.com
Note on DCO:
If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.
Checklist: