Change supported criteria for Google Authenticator
List Google Authenticator as supported when - hash algorithm is SHA256 or SHA512 - number of digits is 8 - OTP type is hotp Signed-off-by: Tero Saarni <tero.saarni@est.tech>
This commit is contained in:
parent
244ecd45a7
commit
e06fcbe6ae
4 changed files with 30 additions and 26 deletions
|
@ -22,15 +22,10 @@ public class GoogleAuthenticatorProvider implements OTPApplicationProviderFactor
|
|||
|
||||
@Override
|
||||
public boolean supports(OTPPolicy policy) {
|
||||
if (policy.getDigits() != 6) {
|
||||
return false;
|
||||
if (policy.getType().equals("totp")) {
|
||||
return policy.getPeriod() == 30;
|
||||
}
|
||||
|
||||
if (!policy.getAlgorithm().equals("HmacSHA1")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return policy.getType().equals("totp") && policy.getPeriod() == 30;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -318,7 +318,7 @@ public class AppInitiatedActionTotpSetupTest extends AbstractAppInitiatedActionT
|
|||
String pageSource = driver.getPageSource();
|
||||
|
||||
assertTrue(pageSource.contains("FreeOTP"));
|
||||
assertFalse(pageSource.contains("Google Authenticator"));
|
||||
assertTrue(pageSource.contains("Google Authenticator"));
|
||||
|
||||
totpPage.clickManual();
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ public class RequiredActionTotpSetupTest extends AbstractTestRealmKeycloakTest {
|
|||
String pageSource = driver.getPageSource();
|
||||
|
||||
assertTrue(pageSource.contains("FreeOTP"));
|
||||
assertFalse(pageSource.contains("Google Authenticator"));
|
||||
assertTrue(pageSource.contains("Google Authenticator"));
|
||||
assertFalse(pageSource.contains("Microsoft Authenticator"));
|
||||
|
||||
totpPage.clickManual();
|
||||
|
|
|
@ -1027,8 +1027,17 @@ public class RealmTest extends AbstractAdminTest {
|
|||
rep = realm.toRepresentation();
|
||||
|
||||
supportedApplications = rep.getOtpSupportedApplications();
|
||||
assertThat(supportedApplications, hasSize(1));
|
||||
assertThat(supportedApplications, containsInAnyOrder("totpAppFreeOTPName"));
|
||||
assertThat(supportedApplications, hasSize(2));
|
||||
assertThat(supportedApplications, containsInAnyOrder("totpAppFreeOTPName", "totpAppGoogleName"));
|
||||
|
||||
rep.setOtpPolicyType("hotp");
|
||||
realm.update(rep);
|
||||
|
||||
rep = realm.toRepresentation();
|
||||
|
||||
supportedApplications = rep.getOtpSupportedApplications();
|
||||
assertThat(supportedApplications, hasSize(2));
|
||||
assertThat(supportedApplications, containsInAnyOrder("totpAppFreeOTPName", "totpAppGoogleName"));
|
||||
}
|
||||
|
||||
private void setupTestAppAndUser() {
|
||||
|
|
Loading…
Reference in a new issue