-
Notifications
You must be signed in to change notification settings - Fork 80
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
refactor(accesscontrol): deterministic cache key hashing #292
Conversation
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 fine, apart from a trivial typo
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.
thx
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 gone over this in fine detail, and it looks fine.
It improves the test coverage a fair bit, but there's still a lot of untested code that we can address when we next touch these files.
818ff7a
to
f2f43a2
Compare
@ericpromislow please take another look, I've addressed Kevin's feedback but it didn't affect core of this PR. |
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.
Works and looks ok
Issue: rancher/rancher#47460
Problem
The current
AccessFor
implementation calculates the cache key for a given user based on the resource version of Roles/ClusterRoles associated via RoleBindings/ClusterRoleBindings. While this is correct, in the case of a cache miss that information that was previously used to calculate the hash is no used but instead retrieved again. Finally, the previously-calculated hash is used as key to store the generated AccessSet into the cache.This approach Introduces the chance for a race condition, which this PR is meant to fix by using the same data used to calculate the hash to later generate the AccessSet in case of a cache miss.
Summary
(please take a look at the commits view for more details)