config: use config.Config instead of config.Options everywhere

This commit is contained in:
Caleb Doxsey 2022-08-26 15:39:50 -06:00
parent 5f51510e91
commit 1b80e8a6c2
40 changed files with 484 additions and 412 deletions

View file

@ -39,18 +39,18 @@ func ValidateOptions(o *config.Options) error {
// Authenticate contains data required to run the authenticate service.
type Authenticate struct {
cfg *authenticateConfig
options *atomicutil.Value[*config.Options]
state *atomicutil.Value[*authenticateState]
webauthn *webauthn.Handler
cfg *authenticateConfig
currentConfig *atomicutil.Value[*config.Config]
state *atomicutil.Value[*authenticateState]
webauthn *webauthn.Handler
}
// New validates and creates a new authenticate service from a set of Options.
func New(cfg *config.Config, options ...Option) (*Authenticate, error) {
a := &Authenticate{
cfg: getAuthenticateConfig(options...),
options: config.NewAtomicOptions(),
state: atomicutil.NewValue(newAuthenticateState()),
cfg: getAuthenticateConfig(options...),
currentConfig: atomicutil.NewValue(cfg),
state: atomicutil.NewValue(newAuthenticateState()),
}
a.webauthn = webauthn.New(a.getWebauthnState)
@ -69,7 +69,7 @@ func (a *Authenticate) OnConfigChange(ctx context.Context, cfg *config.Config) {
return
}
a.options.Store(cfg.Options)
a.currentConfig.Store(cfg)
if state, err := newAuthenticateStateFromConfig(cfg); err != nil {
log.Error(ctx).Err(err).Msg("authenticate: failed to update state")
} else {