KEYCLOAK-13253 read rpId from policy in WebAuthnAuthenticator

A new method, getRpID, is created.
This commit is contained in:
Phy 2020-03-06 23:48:41 -05:00 committed by Marek Posolda
parent 83461d033b
commit 2b35321b7c

View file

@ -76,8 +76,7 @@ public class WebAuthnAuthenticator implements Authenticator, CredentialValidator
form.setAttribute(WebAuthnConstants.CHALLENGE, challengeValue);
WebAuthnPolicy policy = getWebAuthnPolicy(context);
String rpId = policy.getRpId();
if (rpId == null || rpId.isEmpty()) rpId = context.getUriInfo().getBaseUri().getHost();
String rpId = getRpID(context);
form.setAttribute(WebAuthnConstants.RP_ID, rpId);
UserModel user = context.getUser();
@ -108,6 +107,13 @@ public class WebAuthnAuthenticator implements Authenticator, CredentialValidator
return context.getRealm().getWebAuthnPolicy();
}
protected String getRpID(AuthenticationFlowContext context){
WebAuthnPolicy policy = getWebAuthnPolicy(context);
String rpId = policy.getRpId();
if (rpId == null || rpId.isEmpty()) rpId = context.getUriInfo().getBaseUri().getHost();
return rpId;
}
protected String getCredentialType() {
return WebAuthnCredentialModel.TYPE_TWOFACTOR;
}
@ -126,7 +132,7 @@ public class WebAuthnAuthenticator implements Authenticator, CredentialValidator
}
String baseUrl = UriUtils.getOrigin(context.getUriInfo().getBaseUri());
String rpId = context.getUriInfo().getBaseUri().getHost();
String rpId = getRpID(context);
Origin origin = new Origin(baseUrl);
Challenge challenge = new DefaultChallenge(context.getAuthenticationSession().getAuthNote(WebAuthnConstants.AUTH_CHALLENGE_NOTE));