@@ -441,17 +441,7 @@ func (a *auth) FromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) {
441441 a .MinimumPasswordLength = cast .IntToUint (ValOrDefault (remoteConfig .PasswordMinLength , 0 ))
442442 prc := ValOrDefault (remoteConfig .PasswordRequiredCharacters , "" )
443443 a .PasswordRequirements = NewPasswordRequirement (v1API .UpdateAuthConfigBodyPasswordRequiredCharacters (prc ))
444- passkeyDisplayName := ValOrDefault (remoteConfig .WebauthnRpDisplayName , "" )
445- passkeyId := ValOrDefault (remoteConfig .WebauthnRpId , "" )
446- passkeyOrigins := ValOrDefault (remoteConfig .WebauthnRpOrigins , "" )
447- if remoteConfig .PasskeyEnabled || passkeyDisplayName != "" || passkeyId != "" || passkeyOrigins != "" {
448- if a .Passkey == nil {
449- a .Passkey = & passkey {}
450- }
451- a .Passkey .fromAuthConfig (remoteConfig )
452- } else {
453- a .Passkey = nil
454- }
444+ a .Passkey .fromAuthConfig (remoteConfig )
455445 a .RateLimit .fromAuthConfig (remoteConfig )
456446 if s := a .Email .Smtp ; s != nil && s .Enabled {
457447 a .RateLimit .EmailSent = cast .IntToUint (ValOrDefault (remoteConfig .RateLimitEmailSent , 0 ))
@@ -512,17 +502,25 @@ func (c *captcha) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) {
512502}
513503
514504func (p passkey ) toAuthConfigBody (body * v1API.UpdateAuthConfigBody ) {
515- body .PasskeyEnabled = cast .Ptr (p .Enabled )
516- body .WebauthnRpDisplayName = nullable .NewNullableWithValue (p .RpDisplayName )
517- body .WebauthnRpId = nullable .NewNullableWithValue (p .RpId )
518- body .WebauthnRpOrigins = nullable .NewNullableWithValue (strings .Join (p .RpOrigins , "," ))
505+ if body .PasskeyEnabled = cast .Ptr (p .Enabled ); p .Enabled {
506+ body .WebauthnRpDisplayName = nullable .NewNullableWithValue (p .RpDisplayName )
507+ body .WebauthnRpId = nullable .NewNullableWithValue (p .RpId )
508+ body .WebauthnRpOrigins = nullable .NewNullableWithValue (strings .Join (p .RpOrigins , "," ))
509+ }
519510}
520511
521512func (p * passkey ) fromAuthConfig (remoteConfig v1API.AuthConfigResponse ) {
513+ // When local config is not set, we assume platform defaults should not change
514+ if p == nil {
515+ return
516+ }
517+ // Ignore disabled passkey fields to minimise config diff
518+ if p .Enabled {
519+ p .RpDisplayName = ValOrDefault (remoteConfig .WebauthnRpDisplayName , "" )
520+ p .RpId = ValOrDefault (remoteConfig .WebauthnRpId , "" )
521+ p .RpOrigins = strToArr (ValOrDefault (remoteConfig .WebauthnRpOrigins , "" ))
522+ }
522523 p .Enabled = remoteConfig .PasskeyEnabled
523- p .RpDisplayName = ValOrDefault (remoteConfig .WebauthnRpDisplayName , "" )
524- p .RpId = ValOrDefault (remoteConfig .WebauthnRpId , "" )
525- p .RpOrigins = strToArr (ValOrDefault (remoteConfig .WebauthnRpOrigins , "" ))
526524}
527525
528526func (h hook ) toAuthConfigBody (body * v1API.UpdateAuthConfigBody ) {
0 commit comments