-
Notifications
You must be signed in to change notification settings - Fork 4
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
IAM-1013 Implement granular payload authorization check for Group Assign{Roles,Identities}
handlers
#433
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.
let's have a chat on Monday on the middleware vs handler placement
I think that if we can reuse what we have is doable it might be cleaner too, if we can't this solution as is will do great
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.
2 things:
- I agree with alessandro that probably the authorization logic should be moved elsewhere
- Please correct me if I'm wrong, but the logic in this PR is
user A can assign roles Rs to group B IF user A can view roles Rs AND user A can edit group B
anduser A can add users Xs to group B if user A can view users Xs AND user A can edit group B
. This does not sound correct. I remember there was a doc about this, but I don't remember if it ever reached an agreement.
i'll have a bit of a poke around and see how the code looks like, most likely to do it properly it will require a bit of refactoring that i'm not keen on committing right now
regarding users seeing group details ( eg: an admin could create a blacklist of users requiring extra safeguarding measures without this group showing up |
@nsklikas For number 1: there are multiple reasons to avoid this logic in the middleware. Also, granular payload authorization stems from resource specific behavior/needs, so it's something that (in this case) the Groups service should know about. Keep in mind that the current autz middleware + converters has a lot of logic already, meaning "it's already doing too much". Not to mention that the middleware would have to deserialize the payload and be in the know of which type to use, so we'd have less separation of concerns and (especially) more inter module dependencies. |
Regarding 2, currently the authz logic for these handlers is spread across |
had a quick go at working our the "middleware" solution 91d5094 a couple of issues (which kinda match concerns of you all)
IMHO what we should do is:
long story short, as much as i'd like to make the change i don't think we are in a position to do it without a not so minor refactor i stand by my idea that converters should do more and take care of authorization, be it URI or payload, but code maintainability should be paramount so if we can't make it happen then ain't happening |
@nsklikas I share this point with Nikos, I believe that if logic is in the middleware than it needs to be able to handle things without custom (or "branch" specific) logic implemented with too many if-then-else.
I don't understand what should be implemented first, if tuples are used to check against OpenFGA than the "new" tuples added to the check should return "false" and the middleware would block with 403. Or I'm missing something.
Created #436
This is something that leads me to think we have too many structs for same-purpose implementations, we should take a scan of the code and uniform things.
Created issue #438
I'll leave the creation of issues for this to you guys since you're probably going to lead this refinement/development.
Agree on code maintanability. As far as my opinion on where to put things, I wrote it in response to Nikos' comments. So if also @nsklikas agree we could proceed with this. |
9a1171a
to
6c7e9e5
Compare
issue is when we are not able to parse the payload therefore we cant build new tuples, i was not able to find an "always fail" tuple so in case of error we should abort the call, without aborting we would have no tuples to verify which would mean "no permissions to check, go ahead" |
… funcs + adoption + adjust tests
6c7e9e5
to
7bdb955
Compare
FYI I'm rebasing on main after new pushes arrive. |
Description
This PR adds implementation to check if the Assign{Identities,Roles} operation can be performed.
It leverages a BatchCheck that was previously not exposed on the underling client interface of the OpenFGA service.
Changes
buildGroupMember
-like functionsinternal/authorization/util.go
and introduced functions to build tuple elements for all types in the OpenFGA authorization model