feat: add a custom google backend for sso #27082
Open
+120
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Our current system stores
google-oauth2
uids as emails which makes it so if a customer changes their domain in GSuite, none of their users can login because it's looking against the old email domain. This PR updates our system to use the OpenIDsub
, which is guaranteed to be a unique and consistent identifier for the user.It inherits from the existing class so all other functions will fall to the inheritance.
It's implemented in a way that it has backwards compatibility for existing users and slowly migrates them as they login. Over time this custom class could be removed and it be updated to use the default social core
get_user_id
and setting thesettings.USE_UNIQUE_USER_ID = True
option.Here is the social core method: https://github.com/python-social-auth/social-core/blob/master/social_core/backends/google.py#L12-L20
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Add light tests manually tested: