KEYCLOAK-183 Don't show totp on main login form if totp is required by realm
This commit is contained in:
parent
eea812dfda
commit
5415a878e8
4 changed files with 10 additions and 34 deletions
|
@ -38,8 +38,6 @@ public class LoginBean {
|
|||
|
||||
private String password;
|
||||
|
||||
private List<RequiredCredential> requiredCredentials;
|
||||
|
||||
public LoginBean(RealmBean realm, MultivaluedMap<String, String> formData){
|
||||
|
||||
this.realm = realm;
|
||||
|
@ -48,14 +46,6 @@ public class LoginBean {
|
|||
username = formData.getFirst("username");
|
||||
password = formData.getFirst("password");
|
||||
}
|
||||
|
||||
requiredCredentials = new LinkedList<RequiredCredential>();
|
||||
for (org.keycloak.models.RequiredCredentialModel c : realm.getRealm().getRequiredCredentials()) {
|
||||
if (c.isInput()) {
|
||||
requiredCredentials.add(new RequiredCredential(c.getType(), c.isSecret(), c.getFormLabel()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
@ -66,10 +56,6 @@ public class LoginBean {
|
|||
return password;
|
||||
}
|
||||
|
||||
public List<RequiredCredential> getRequiredCredentials() {
|
||||
return requiredCredentials;
|
||||
}
|
||||
|
||||
public RealmBean getRealm() {
|
||||
return realm;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
<label for="username">${rb.getString('username')}</label><input id="username" name="username" value="${login.username!''}" type="text" autofocus />
|
||||
</div>
|
||||
|
||||
<#list login.requiredCredentials as c>
|
||||
<div>
|
||||
<label for="${c.name}">${rb.getString(c.label)}</label><input id="${c.name}" name="${c.name}" type="${c.inputType}" />
|
||||
<label for="password">${rb.getString('password')}</label><input id="password" name="password" type="password" />
|
||||
</div>
|
||||
</#list>
|
||||
|
||||
<div class="form-buttons">
|
||||
<input class="btn-primary" name="login" type="submit" value="Log In"/>
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.keycloak.testsuite.pages.AppPage;
|
|||
import org.keycloak.testsuite.pages.AppPage.RequestType;
|
||||
import org.keycloak.testsuite.pages.LoginConfigTotpPage;
|
||||
import org.keycloak.testsuite.pages.LoginPage;
|
||||
import org.keycloak.testsuite.pages.LoginTotpPage;
|
||||
import org.keycloak.testsuite.pages.RegisterPage;
|
||||
import org.keycloak.testsuite.rule.KeycloakRule;
|
||||
import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup;
|
||||
|
@ -70,6 +71,9 @@ public class RequiredActionTotpSetupTest {
|
|||
@WebResource
|
||||
protected LoginPage loginPage;
|
||||
|
||||
@WebResource
|
||||
protected LoginTotpPage loginTotpPage;
|
||||
|
||||
@WebResource
|
||||
protected LoginConfigTotpPage totpPage;
|
||||
|
||||
|
@ -113,7 +117,8 @@ public class RequiredActionTotpSetupTest {
|
|||
oauth.openLogout();
|
||||
|
||||
loginPage.open();
|
||||
loginPage.loginTotp("test-user@localhost", "password", totp.generate(totpSecret));
|
||||
loginPage.login("test-user@localhost", "password");
|
||||
loginTotpPage.login(totp.generate(totpSecret));
|
||||
|
||||
Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
|
||||
}
|
||||
|
@ -146,7 +151,7 @@ public class RequiredActionTotpSetupTest {
|
|||
Assert.assertFalse(totpPage.isCurrent());
|
||||
|
||||
// Login with one-time password
|
||||
loginPage.loginTotp("setupTotp2", "password2", totp.generate(totpCode));
|
||||
loginTotpPage.login(totp.generate(totpCode));
|
||||
|
||||
// Open account page
|
||||
accountTotpPage.open();
|
||||
|
|
|
@ -73,19 +73,6 @@ public class LoginPage extends AbstractPage {
|
|||
cancelButton.click();
|
||||
}
|
||||
|
||||
public void loginTotp(String username, String password, String code) {
|
||||
usernameInput.clear();
|
||||
usernameInput.sendKeys(username);
|
||||
|
||||
passwordInput.clear();
|
||||
passwordInput.sendKeys(password);
|
||||
|
||||
totp.clear();
|
||||
totp.sendKeys(code);
|
||||
|
||||
submitButton.click();
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return loginErrorMessage != null ? loginErrorMessage.getText() : null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue