Improvements to Google group authentication #172
Description
So we're finally looking closer into group level access with oauth2_proxy and we discovered some problems with the current approach.
- Either Google added or I missed the fact that you can query the list of groups a user is a member of in a single call https://developers.google.com/admin-sdk/directory/v1/reference/groups/list passing in userKey.
- Once someone successfully authenticates with any oauth2_proxy, theoretically they could successfully log into a different proxy instance that does restricts users to a group that user is not a part of because it uses the same cookie name. This assumes the cookie is valid and doesn't need to be refreshed, therefore the second proxy would forego the need to check group membership. The workaround would be to use different cookie names for group restricted services but that seems hacky. Ideally the same oauth2_proxy cookie payload should be able to be used across your infrastructure, even services that require specific groups. If you try to hit a service where you are not a member of that group you should get a 403 ( I suppose this might cause the cookie to be invalidated, but I don't see a problem with that )
For 1, this is easy enough to do so I'll work on that however for 2 I'm not sure what would be the best solution. #28 mentioned the ability to pass a header to backend services that shows the list of groups a member is a part of. The main issue that I can think of is how to store the list of groups a member is a part of in a secure, immutable way so that oauth2_proxy can easily check group membership on every request and also pass the group membership as a header. Do I add onto the SessionState type to add a Groups field that also gets serialized and encrypted into the oauth cookie? Perhaps instead I add a Provider specific part to the SessionState that allows each provider to put whatever it wants in there and it's up the the provider on how to store and parse it beyond it being a string in SessionState ( So for google, it can store groups, but github could store org and team memberships). Does anyone have a different idea on how this can be done?