Skip to content
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

OIDC to Stytch migration #63

Merged
merged 11 commits into from
Aug 22, 2024
Merged

OIDC to Stytch migration #63

merged 11 commits into from
Aug 22, 2024

Conversation

patrislav
Copy link
Member

This adds 3 pieces required to perform account migrations. Please note that a "migration" in this context does not involve removing the original account or making it unavailable by any means. Instead the migration process -- when completed -- simply enables clients to sign in users using either the original or "migrated" account created in the migration process. Thanks to this, clients may update to using the new system at their own pace.

  1. Hook in the RegisterSession intent handler that continuously migrates any accounts that match the config. This is what enables the clients the freedom to update at any time as accounts will continue to be migrated even after the initial batch manual migration is complete.
  2. NextMigrationBatch returns the next paginated batch of accounts identifiers that need to be migrated.
  3. ProcessMigrationBatch creates the new accounts for the specified batch of account identifiers.

The last two require the admin level JWT as access control. However, other than being relatively resource-intensive, these are non-destructive and idempotent, as long as the config is correct. The manual process is equivalent to the automatic hooks except being used on all accounts.



enum Migration: string
- OIDCToStytch
Copy link
Member

Choose a reason for hiding this comment

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

for migration names, what do you think if we prefix by a number?

for example update the code to..

enum Migration: string
  - 001_ OIDCToStytch

then for the Email migration in the other PR we have - 002_ OIDCToEmail .. and we will always ensure migrations run in order. However, maybe its not necessary as they don't necessarily have a dependency on eachother

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no dependency between migrations, they're intended to be idempotent and be runnable in any order.

Also is this a webrpc specific syntax? Wouldn't this not work anyway because of the generated names starting with numbers?

Copy link
Member

Choose a reason for hiding this comment

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

if there is no requirement for order of migrations, then there probably isn't any value to this as with typical migrations like in RDMBS'

as for starting with a number, if that is problem, could always prefix with a letter like, "M001_XXX" .. but doesn't sound like we need this. The idea of migration numbers is that you record which migrations have been run, so they don't get triggered again once they are run, which, we may want to do in fact..

Copy link
Member Author

Choose a reason for hiding this comment

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

In the case of authenticator migrations, each of them is idempotent so there's no risk in triggering them multiple times

data/account.go Show resolved Hide resolved
@patrislav patrislav merged commit 8473a04 into master Aug 22, 2024
2 checks passed
@patrislav patrislav deleted the stytch-migration branch August 22, 2024 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants