Java Code Examples for org.keycloak.representations.idm.RealmRepresentation#setWebAuthnPolicyUserVerificationRequirement()
The following examples show how to use
org.keycloak.representations.idm.RealmRepresentation#setWebAuthnPolicyUserVerificationRequirement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebAuthnRegisterAndLoginTest.java From keycloak with Apache License 2.0 | 5 votes |
public void restoreWebAuthnRealmSettings() { RealmRepresentation rep = testRealm().toRepresentation(); rep.setWebAuthnPolicySignatureAlgorithms(signatureAlgorithms); rep.setWebAuthnPolicyAttestationConveyancePreference(attestationConveyancePreference); rep.setWebAuthnPolicyAuthenticatorAttachment(authenticatorAttachment); rep.setWebAuthnPolicyRequireResidentKey(requireResidentKey); rep.setWebAuthnPolicyRpEntityName(rpEntityName); rep.setWebAuthnPolicyUserVerificationRequirement(userVerificationRequirement); rep.setWebAuthnPolicyRpId(rpId); rep.setWebAuthnPolicyCreateTimeout(createTimeout); rep.setWebAuthnPolicyAvoidSameAuthenticatorRegister(avoidSameAuthenticatorRegister); rep.setWebAuthnPolicyAcceptableAaguids(acceptableAaguids); testRealm().update(rep); }
Example 2
Source File: WebAuthnRegisterAndLoginTest.java From keycloak with Apache License 2.0 | 4 votes |
@Test public void registerUserSuccess() { String username = "registerUserSuccess"; String password = "password"; String email = "registerUserSuccess@email"; try { RealmRepresentation rep = backupWebAuthnRealmSettings(); rep.setWebAuthnPolicySignatureAlgorithms(Arrays.asList("ES256")); rep.setWebAuthnPolicyAttestationConveyancePreference("none"); rep.setWebAuthnPolicyAuthenticatorAttachment("cross-platform"); rep.setWebAuthnPolicyRequireResidentKey("No"); rep.setWebAuthnPolicyRpId(null); rep.setWebAuthnPolicyUserVerificationRequirement("preferred"); rep.setWebAuthnPolicyAcceptableAaguids(Arrays.asList(ALL_ZERO_AAGUID)); testRealm().update(rep); loginPage.open(); loginPage.clickRegister(); registerPage.assertCurrent(); String authenticatorLabel = RandomString.randomCode(24); registerPage.register("firstName", "lastName", email, username, password, password); // User was registered. Now he needs to register WebAuthn credential webAuthnRegisterPage.registerWebAuthnCredential(authenticatorLabel); appPage.assertCurrent(); assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); appPage.openAccount(); // confirm that registration is successfully completed String userId = events.expectRegister(username, email).assertEvent().getUserId(); // confirm registration event EventRepresentation eventRep = events.expectRequiredAction(EventType.CUSTOM_REQUIRED_ACTION) .user(userId) .detail(Details.CUSTOM_REQUIRED_ACTION, WebAuthnRegisterFactory.PROVIDER_ID) .detail(WebAuthnConstants.PUBKEY_CRED_LABEL_ATTR, authenticatorLabel) .assertEvent(); String regPubKeyCredentialId = eventRep.getDetails().get(WebAuthnConstants.PUBKEY_CRED_ID_ATTR); //String regPubKeyCredentialAaguid = eventRep.getDetails().get("public_key_credential_aaguid"); //String regPubKeyCredentialLabel = eventRep.getDetails().get("public_key_credential_label"); // confirm login event String sessionId = events.expectLogin() .user(userId) .detail(Details.CUSTOM_REQUIRED_ACTION, WebAuthnRegisterFactory.PROVIDER_ID) .detail(WebAuthnConstants.PUBKEY_CRED_LABEL_ATTR, authenticatorLabel) .assertEvent().getSessionId(); // confirm user registered assertUserRegistered(userId, username.toLowerCase(), email.toLowerCase()); assertRegisteredCredentials(userId, ALL_ZERO_AAGUID, "none"); // logout by user appPage.logout(); // confirm logout event events.expectLogout(sessionId) .user(userId) .assertEvent(); // login by user loginPage.open(); loginPage.login(username, password); // User is authenticated by Chrome WebAuthN testing API appPage.assertCurrent(); assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); appPage.openAccount(); // confirm login event sessionId = events.expectLogin() .user(userId) .detail(WebAuthnConstants.PUBKEY_CRED_ID_ATTR, regPubKeyCredentialId) // .detail("web_authn_authenticator_user_verification_checked", Boolean.FALSE.toString()) .assertEvent().getSessionId(); // logout by user appPage.logout(); // confirm logout event events.expectLogout(sessionId) .user(userId) .assertEvent(); } finally { restoreWebAuthnRealmSettings(); } }