Skip to content

feat(identity): AuthProvider dual-writes to IdentityProvider - #26932

Closed
leedongwei wants to merge 4 commits into
dlee/auth-dual-write-identity-providerfrom
dlee/auth-dual-write-auth-provider
Closed

leedongwei wants to merge 4 commits into
dlee/auth-dual-write-identity-providerfrom
dlee/auth-dual-write-auth-provider

Conversation

@leedongwei

@leedongwei leedongwei commented Jun 28, 2021 •

Copy link
Copy Markdown
Contributor

This is a series of PR to merge IdentityProvider and AuthProvider into 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

@wedamija wedamija left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Comment on lines +159 to +175
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,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run every time an AuthProvider is saved, not just on create. I feel like you want to use create_or_update here.

Comment on lines +61 to +68
@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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leedongwei
leedongwei force-pushed the dlee/auth-dual-write-identity-provider branch from d4fd593 to fdd505e Compare June 30, 2021 09:01
@leedongwei
leedongwei requested a review from a team as a code owner June 30, 2021 09:01
@github-actions

Copy link
Copy Markdown
Contributor

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 Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@leedongwei leedongwei closed this Sep 30, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2021
@mgaeta
mgaeta deleted the dlee/auth-dual-write-auth-provider branch March 18, 2022 20:28

This branch was successfully deployed

2 active deployments
Preview – sentry — 61bf6f31 Deployed Jun 28, 2021 by vercel[bot]
Preview – storybook — 61bf6f31 Deployed Jun 28, 2021 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants