fix: passkeys work independently of MFA mode
When MFA mode is off but passkeys are enabled, WebAuthn + BackupCode factors are still synced to Logto. Previously, MFA off cleared all factors including WebAuthn, so passkey enrollment was never offered. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,14 +40,17 @@ public class LogtoStartupConfig {
|
||||
var policy = authPolicyRepository.getPolicy();
|
||||
String mfaMode = policy.getMfaMode();
|
||||
boolean mfaEnabled = !"off".equals(mfaMode);
|
||||
boolean passkeyEnabled = policy.isPasskeyEnabled();
|
||||
|
||||
if (!mfaEnabled) {
|
||||
logtoClient.updateSignInExperience(Map.of(
|
||||
"mfa", Map.of("factors", List.of(), "policy", "UserControlled")));
|
||||
return;
|
||||
List<String> factors = new ArrayList<>();
|
||||
if (mfaEnabled) {
|
||||
factors.add("Totp");
|
||||
}
|
||||
if (mfaEnabled || passkeyEnabled) {
|
||||
factors.add("WebAuthn");
|
||||
factors.add("BackupCode");
|
||||
}
|
||||
|
||||
List<String> factors = new ArrayList<>(List.of("Totp", "WebAuthn", "BackupCode"));
|
||||
String logtoPolicy = "required".equals(mfaMode) ? "Mandatory" : "UserControlled";
|
||||
|
||||
logtoClient.updateSignInExperience(Map.of(
|
||||
|
||||
@@ -73,14 +73,17 @@ public class VendorAuthPolicyController {
|
||||
try {
|
||||
String mfaMode = policy.getMfaMode();
|
||||
boolean mfaEnabled = !"off".equals(mfaMode);
|
||||
boolean passkeyEnabled = policy.isPasskeyEnabled();
|
||||
|
||||
if (!mfaEnabled) {
|
||||
logtoClient.updateSignInExperience(Map.of(
|
||||
"mfa", Map.of("factors", List.of(), "policy", "UserControlled")));
|
||||
return;
|
||||
List<String> factors = new ArrayList<>();
|
||||
if (mfaEnabled) {
|
||||
factors.add("Totp");
|
||||
}
|
||||
// Passkeys are always available when enabled, regardless of MFA mode
|
||||
if (mfaEnabled || passkeyEnabled) {
|
||||
factors.add("WebAuthn");
|
||||
factors.add("BackupCode");
|
||||
}
|
||||
|
||||
List<String> factors = new ArrayList<>(List.of("Totp", "WebAuthn", "BackupCode"));
|
||||
|
||||
String logtoPolicy = "required".equals(mfaMode) ? "Mandatory" : "UserControlled";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user