From 7ec0dad88f5e06674442d9b43bfb98efaea94e31 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 5 Jan 2016 18:09:43 -0200 Subject: [PATCH 1/2] Make use of display name by default for TOTP - use realm name just in case of display name is not available --- .../java/org/keycloak/account/freemarker/model/TotpBean.java | 2 -- .../java/org/keycloak/login/freemarker/model/TotpBean.java | 2 -- model/api/src/main/java/org/keycloak/models/OTPPolicy.java | 5 ++++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/TotpBean.java b/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/TotpBean.java index 419f3213e5..11363fa05b 100755 --- a/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/TotpBean.java +++ b/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/TotpBean.java @@ -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(); diff --git a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/TotpBean.java b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/TotpBean.java index 6c9def495f..eae56dc39e 100755 --- a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/TotpBean.java +++ b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/TotpBean.java @@ -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(); diff --git a/model/api/src/main/java/org/keycloak/models/OTPPolicy.java b/model/api/src/main/java/org/keycloak/models/OTPPolicy.java index 157842e94e..8d76bb9b83 100755 --- a/model/api/src/main/java/org/keycloak/models/OTPPolicy.java +++ b/model/api/src/main/java/org/keycloak/models/OTPPolicy.java @@ -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"); From 2a8e868bc18ad6e9bd8c909a6e976bd668c6796e Mon Sep 17 00:00:00 2001 From: Marko Strukelj Date: Tue, 5 Jan 2016 22:52:16 +0100 Subject: [PATCH 2/2] Fix missing offlineSession local-cache config for demo-dist --- distribution/demo-dist/src/main/xslt/standalone.xsl | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/demo-dist/src/main/xslt/standalone.xsl b/distribution/demo-dist/src/main/xslt/standalone.xsl index 2110908134..7a90804995 100755 --- a/distribution/demo-dist/src/main/xslt/standalone.xsl +++ b/distribution/demo-dist/src/main/xslt/standalone.xsl @@ -70,6 +70,7 @@ +