mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-26 13:50:48 +00:00
realm name in OTP
This commit is contained in:
+1
-1
@@ -169,7 +169,7 @@ public class FreeMarkerLoginForms implements LoginForms {
|
||||
|
||||
switch (page) {
|
||||
case LOGIN_CONFIG_TOTP:
|
||||
attributes.put("totp", new TotpBean(user, baseUri));
|
||||
attributes.put("totp", new TotpBean(realm, user, baseUri));
|
||||
break;
|
||||
case LOGIN_UPDATE_PROFILE:
|
||||
attributes.put("user", new ProfileBean(user));
|
||||
|
||||
+5
-2
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.keycloak.login.freemarker.model;
|
||||
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.models.utils.Base32;
|
||||
|
||||
@@ -38,8 +39,10 @@ public class TotpBean {
|
||||
private String totpSecretEncoded;
|
||||
private boolean enabled;
|
||||
private String contextUrl;
|
||||
private String realmName;
|
||||
|
||||
public TotpBean(UserModel user, URI baseUri) {
|
||||
public TotpBean(RealmModel realm, UserModel user, URI baseUri) {
|
||||
this.realmName = realm.getName();
|
||||
this.enabled = user.isTotp();
|
||||
this.contextUrl = baseUri.getPath();
|
||||
|
||||
@@ -78,7 +81,7 @@ public class TotpBean {
|
||||
}
|
||||
|
||||
public String getTotpSecretQrCodeUrl() throws UnsupportedEncodingException {
|
||||
String contents = URLEncoder.encode("otpauth://totp/keycloak?secret=" + totpSecretEncoded, "utf-8");
|
||||
String contents = URLEncoder.encode("otpauth://totp/" + realmName + "?secret=" + totpSecretEncoded, "utf-8");
|
||||
return contextUrl + "qrcode" + "?size=246x246&contents=" + contents;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user