Skip to content

Commit

Permalink
rpc/migration: limit email migration to conf'd projects
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav committed Aug 23, 2024
1 parent 94e2543 commit 0c51977
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type OIDCToStytchConfig struct {
}

type EmailMigrationConfig struct {
Enabled bool `toml:"enabled"`
IssuerPrefix string `toml:"issuer_prefix"`
Enabled bool `toml:"enabled"`
IssuerPrefix string `toml:"issuer_prefix"`
Projects []uint64 `toml:"projects"`
}
1 change: 1 addition & 0 deletions etc/waas-auth.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ QwIDAQAB
[migrations.oidc_to_email]
enabled = true
issuer_prefix = "https://cognito-idp.ca-central-1.amazonaws.com/"
projects = [694]

4 changes: 4 additions & 0 deletions rpc/migration/oidc_to_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"

"github.com/0xsequence/waas-authenticator/config"
Expand All @@ -28,6 +29,9 @@ func (m *OIDCToEmail) OnRegisterSession(ctx context.Context, originalAccount *da
if originalAccount.ProjectID != tntData.ProjectID {
return errors.New("project id does not match")
}
if !slices.Contains(m.config.Projects, originalAccount.ProjectID) {
return nil
}
if originalAccount.Identity.Type != proto.IdentityType_OIDC {
return nil
}
Expand Down

0 comments on commit 0c51977

Please sign in to comment.