Merge pull request #1982 from abstractj/KEYCLOAK-1919
Make use of display name by default for TOTP
This commit is contained in:
commit
b2a3918fc3
3 changed files with 4 additions and 5 deletions
|
@ -41,11 +41,9 @@ public class TotpBean {
|
|||
private final String totpSecretEncoded;
|
||||
private final boolean enabled;
|
||||
private final String contextUrl;
|
||||
private final String realmName;
|
||||
private final String keyUri;
|
||||
|
||||
public TotpBean(KeycloakSession session, RealmModel realm, UserModel user, URI baseUri) {
|
||||
this.realmName = realm.getName();
|
||||
this.enabled = session.users().configuredForCredentialType(realm.getOTPPolicy().getType(), realm, user);
|
||||
this.contextUrl = baseUri.getPath();
|
||||
|
||||
|
|
|
@ -39,11 +39,9 @@ public class TotpBean {
|
|||
private final String totpSecretEncoded;
|
||||
private final boolean enabled;
|
||||
private final String contextUrl;
|
||||
private final String realmName;
|
||||
private final String keyUri;
|
||||
|
||||
public TotpBean(RealmModel realm, UserModel user, URI baseUri) {
|
||||
this.realmName = realm.getName();
|
||||
this.enabled = user.isOtpEnabled();
|
||||
this.contextUrl = baseUri.getPath();
|
||||
|
||||
|
|
|
@ -97,8 +97,11 @@ public class OTPPolicy implements Serializable {
|
|||
|
||||
public String getKeyURI(RealmModel realm, UserModel user, String secret) {
|
||||
|
||||
String displayName = realm.getDisplayName();
|
||||
String uri = null;
|
||||
uri = "otpauth://" + type + "/" + realm.getName() + ":" + user.getUsername() + "?secret=" +
|
||||
|
||||
if (displayName == null || displayName.isEmpty()) { displayName = realm.getName(); }
|
||||
uri = "otpauth://" + type + "/" + displayName + ":" + user.getUsername() + "?secret=" +
|
||||
Base32.encode(secret.getBytes()) + "&digits=" + digits + "&algorithm=" + algToKeyUriAlg.get(algorithm);
|
||||
try {
|
||||
uri += "&issuer=" + URLEncoder.encode(realm.getName(), "UTF-8");
|
||||
|
|
Loading…
Reference in a new issue