Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
1cbe5c4c80
4 changed files with 5 additions and 5 deletions
|
@ -70,6 +70,7 @@
|
||||||
<local-cache name="realms"/>
|
<local-cache name="realms"/>
|
||||||
<local-cache name="users"/>
|
<local-cache name="users"/>
|
||||||
<local-cache name="sessions"/>
|
<local-cache name="sessions"/>
|
||||||
|
<local-cache name="offlineSessions"/>
|
||||||
<local-cache name="loginFailures"/>
|
<local-cache name="loginFailures"/>
|
||||||
</cache-container>
|
</cache-container>
|
||||||
<xsl:apply-templates select="node()|@*"/>
|
<xsl:apply-templates select="node()|@*"/>
|
||||||
|
|
|
@ -41,11 +41,9 @@ public class TotpBean {
|
||||||
private final String totpSecretEncoded;
|
private final String totpSecretEncoded;
|
||||||
private final boolean enabled;
|
private final boolean enabled;
|
||||||
private final String contextUrl;
|
private final String contextUrl;
|
||||||
private final String realmName;
|
|
||||||
private final String keyUri;
|
private final String keyUri;
|
||||||
|
|
||||||
public TotpBean(KeycloakSession session, RealmModel realm, UserModel user, URI baseUri) {
|
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.enabled = session.users().configuredForCredentialType(realm.getOTPPolicy().getType(), realm, user);
|
||||||
this.contextUrl = baseUri.getPath();
|
this.contextUrl = baseUri.getPath();
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,9 @@ public class TotpBean {
|
||||||
private final String totpSecretEncoded;
|
private final String totpSecretEncoded;
|
||||||
private final boolean enabled;
|
private final boolean enabled;
|
||||||
private final String contextUrl;
|
private final String contextUrl;
|
||||||
private final String realmName;
|
|
||||||
private final String keyUri;
|
private final String keyUri;
|
||||||
|
|
||||||
public TotpBean(RealmModel realm, UserModel user, URI baseUri) {
|
public TotpBean(RealmModel realm, UserModel user, URI baseUri) {
|
||||||
this.realmName = realm.getName();
|
|
||||||
this.enabled = user.isOtpEnabled();
|
this.enabled = user.isOtpEnabled();
|
||||||
this.contextUrl = baseUri.getPath();
|
this.contextUrl = baseUri.getPath();
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,11 @@ public class OTPPolicy implements Serializable {
|
||||||
|
|
||||||
public String getKeyURI(RealmModel realm, UserModel user, String secret) {
|
public String getKeyURI(RealmModel realm, UserModel user, String secret) {
|
||||||
|
|
||||||
|
String displayName = realm.getDisplayName();
|
||||||
String uri = null;
|
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);
|
Base32.encode(secret.getBytes()) + "&digits=" + digits + "&algorithm=" + algToKeyUriAlg.get(algorithm);
|
||||||
try {
|
try {
|
||||||
uri += "&issuer=" + URLEncoder.encode(realm.getName(), "UTF-8");
|
uri += "&issuer=" + URLEncoder.encode(realm.getName(), "UTF-8");
|
||||||
|
|
Loading…
Reference in a new issue