Repository navigation
feat(identity): AuthProvider dual-writes to IdentityProvider - #26932
leedongwei wants to merge 4 commits into
Conversation
3e115a6 to
61bf6f3
Compare
wedamija
left a comment
There was a problem hiding this comment.
I think this needs tests to validate that this is working as expected. Would recommend testing:
- Creating a new
AuthProvider - Calling
auth_provider.update(<some fields>) - Calling
auth_provider.save()
| def handle_auth_provider_post_save(instance, **kwargs): | ||
| from sentry.models import IdentityProvider | ||
|
|
||
| IdentityProvider.objects.create( | ||
| organization=instance.organization, | ||
| type=instance.provider, | ||
| provider=instance.provider, | ||
| external_id=None, | ||
| provider_id=None, | ||
| config=instance.config, | ||
| is_sso=True, | ||
| sso_default_team=None, | ||
| sso_default_role=instance.default_role, | ||
| sso_default_global_access=instance.default_global_access, | ||
| sso_flags=instance.flags, | ||
| authprovider=instance, | ||
| ) |
There was a problem hiding this comment.
This will run every time an AuthProvider is saved, not just on create. I feel like you want to use create_or_update here.
| @transaction.atomic() | ||
| def save(self, *args, **kwargs): | ||
| """ | ||
| For migration to IdentityProvider. | ||
| Wrap in a transaction so the pre_save will dual-write to IdentityProvider | ||
| """ | ||
| super().save(*args, **kwargs) | ||
|
|
There was a problem hiding this comment.
It's worth checking whether this works when we create a new row. I don't think it will work when we call update(), so you'll need to put this there as well.
d4fd593 to
fdd505e
Compare
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This is a series of PR to merge
IdentityProviderandAuthProviderinto 1 model/table.At the moment, they will need to go through COPS to disconnect their Google identities from their Sentry account. This will make it easier for users to manage their external identities from Slack/MS Teams/Okta/Google/etc.
Part 1: IdentityProvider add new columns (#26930)
Part 2: IdentityProvider dual-write to 2 columns (#26931)
Part 3: AuthProvider dual-write to 2 tables (#26932) ← Here