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

feat: password migration hook #3978

Merged
merged 10 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const (
ViperKeyClientHTTPPrivateIPExceptionURLs = "clients.http.private_ip_exception_urls"
ViperKeyPreviewDefaultReadConsistencyLevel = "preview.default_read_consistency_level"
ViperKeyVersion = "version"
ViperKeyPasswordMigrationHook = "selfservice.flows.login.password_migration"
)

const (
Expand Down Expand Up @@ -290,6 +291,10 @@ type (
Headers map[string]string `json:"headers" koanf:"headers"`
LocalName string `json:"local_name" koanf:"local_name"`
}
PasswordMigrationHook struct {
Enabled bool `json:"enabled"`
Config json.RawMessage `json:"config"`
}
Config struct {
l *logrusx.Logger
p *configx.Provider
Expand Down Expand Up @@ -518,13 +523,12 @@ func (p *Config) cors(ctx context.Context, prefix string) (cors.Options, bool) {
})
}

// Deprecatd: use context-based WithConfigValue instead
func (p *Config) Set(ctx context.Context, key string, value interface{}) error {
func (p *Config) Set(_ context.Context, key string, value interface{}) error {
return p.p.Set(key, value)
}

// Deprecated: use context-based WithConfigValue instead
func (p *Config) MustSet(ctx context.Context, key string, value interface{}) {
// Deprecated: use context-based confighelpers.WithConfigValue instead
func (p *Config) MustSet(_ context.Context, key string, value interface{}) {
if err := p.p.Set(key, value); err != nil {
p.l.WithError(err).Fatalf("Unable to set \"%s\" to \"%s\".", key, value)
}
Expand Down Expand Up @@ -1599,3 +1603,11 @@ func (p *Config) TokenizeTemplate(ctx context.Context, key string) (_ *SessionTo
func (p *Config) DefaultConsistencyLevel(ctx context.Context) crdbx.ConsistencyLevel {
return crdbx.ConsistencyLevelFromString(p.GetProvider(ctx).String(ViperKeyPreviewDefaultReadConsistencyLevel))
}

func (p *Config) PasswordMigrationHook(ctx context.Context) (hook *PasswordMigrationHook) {
hook = new(PasswordMigrationHook)
// Error is ignored on purpose, as we then default to a hook with `enabled = false`.
_ = p.GetProvider(ctx).Unmarshal(ViperKeyPasswordMigrationHook, hook)

return hook
}
Loading
Loading