diff --git a/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json b/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json index f69d0bd7ae..bb918efc31 100755 --- a/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json +++ b/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json @@ -6,7 +6,8 @@ "sslNotRequired": true, "cookieLoginAllowed": true, "registrationAllowed": true, - "automaticRegistrationAfterSocialLogin": true, + "social": true, + "automaticRegistrationAfterSocialLogin": false, "privateKey": "MIICXAIBAAKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQABAoGAfmO8gVhyBxdqlxmIuglbz8bcjQbhXJLR2EoS8ngTXmN1bo2L90M0mUKSdc7qF10LgETBzqL8jYlQIbt+e6TH8fcEpKCjUlyq0Mf/vVbfZSNaVycY13nTzo27iPyWQHK5NLuJzn1xvxxrUeXI6A2WFpGEBLbHjwpx5WQG9A+2scECQQDvdn9NE75HPTVPxBqsEd2z10TKkl9CZxu10Qby3iQQmWLEJ9LNmy3acvKrE3gMiYNWb6xHPKiIqOR1as7L24aTAkEAtyvQOlCvr5kAjVqrEKXalj0Tzewjweuxc0pskvArTI2Oo070h65GpoIKLc9jf+UA69cRtquwP93aZKtW06U8dQJAF2Y44ks/mK5+eyDqik3koCI08qaC8HYq2wVl7G2QkJ6sbAaILtcvD92ToOvyGyeE0flvmDZxMYlvaZnaQ0lcSQJBAKZU6umJi3/xeEbkJqMfeLclD27XGEFoPeNrmdx0q10Azp4NfJAY+Z8KRyQCR2BEG+oNitBOZ+YXF9KCpH3cdmECQHEigJhYg+ykOvr1aiZUMFT72HU0jnmQe2FVekuG+LJUt2Tm7GtMjTFoGpf0JwrVuZN39fOYAlo+nTixgeW7X8Y=", "publicKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB", "requiredCredentials": [ "password" ], diff --git a/forms/src/main/java/org/keycloak/forms/RegisterBean.java b/forms/src/main/java/org/keycloak/forms/RegisterBean.java index 60d247acd1..77d6a8cbe6 100755 --- a/forms/src/main/java/org/keycloak/forms/RegisterBean.java +++ b/forms/src/main/java/org/keycloak/forms/RegisterBean.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; import javax.faces.bean.RequestScoped; import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; @@ -42,6 +43,8 @@ public class RegisterBean { private HashMap formData; + private boolean socialRegistration; + @PostConstruct public void init() { FacesContext ctx = FacesContext.getCurrentInstance(); @@ -49,6 +52,9 @@ public class RegisterBean { this.formData = new HashMap(); + Boolean socialRegistrationAttr = (Boolean)request.getAttribute(FormFlows.SOCIAL_REGISTRATION); + this.socialRegistration = socialRegistrationAttr != null && socialRegistrationAttr; + @SuppressWarnings("unchecked") MultivaluedMap formData = (MultivaluedMap) request.getAttribute(FormFlows.DATA); if (formData != null) { @@ -62,4 +68,8 @@ public class RegisterBean { return formData; } + public boolean isSocialRegistration() { + return socialRegistration; + } + } diff --git a/forms/src/main/java/org/keycloak/forms/SocialBean.java b/forms/src/main/java/org/keycloak/forms/SocialBean.java index b007083044..fab91b165e 100644 --- a/forms/src/main/java/org/keycloak/forms/SocialBean.java +++ b/forms/src/main/java/org/keycloak/forms/SocialBean.java @@ -46,6 +46,9 @@ public class SocialBean { @ManagedProperty(value = "#{realm}") private RealmBean realm; + @ManagedProperty(value = "#{register}") + private RegisterBean registerBean; + @ManagedProperty(value = "#{url}") private UrlBean url; @@ -73,4 +76,32 @@ public class SocialBean { return providers; } + // Display panel with social providers just in case that social is enabled for realm, but we are not in the middle of registration with social + public boolean isDisplaySocialProviders() { + return realm.isSocial() && !registerBean.isSocialRegistration(); + } + + public RealmBean getRealm() { + return realm; + } + + public void setRealm(RealmBean realm) { + this.realm = realm; + } + + public UrlBean getUrl() { + return url; + } + + public void setUrl(UrlBean url) { + this.url = url; + } + + public RegisterBean getRegisterBean() { + return registerBean; + } + + public void setRegisterBean(RegisterBean registerBean) { + this.registerBean = registerBean; + } } diff --git a/forms/src/main/java/org/keycloak/forms/UrlBean.java b/forms/src/main/java/org/keycloak/forms/UrlBean.java index ba006096d1..62017d00bb 100644 --- a/forms/src/main/java/org/keycloak/forms/UrlBean.java +++ b/forms/src/main/java/org/keycloak/forms/UrlBean.java @@ -45,6 +45,9 @@ public class UrlBean { @ManagedProperty(value = "#{realm}") private RealmBean realm; + @ManagedProperty(value = "#{register}") + private RegisterBean registerBean; + @PostConstruct public void init() { FacesContext ctx = FacesContext.getCurrentInstance(); @@ -64,6 +67,14 @@ public class UrlBean { this.realm = realm; } + public RegisterBean getRegisterBean() { + return registerBean; + } + + public void setRegisterBean(RegisterBean registerBean) { + this.registerBean = registerBean; + } + public String getAccessUrl() { return Urls.accountAccessPage(baseURI, realm.getId()).toString(); } @@ -98,7 +109,10 @@ public class UrlBean { public String getRegistrationAction() { if (realm.isSaas()) { + // TODO: saas social registration return Urls.saasRegisterAction(baseURI).toString(); + } else if (registerBean.isSocialRegistration()) { + return Urls.socialRegisterAction(baseURI, realm.getId()).toString(); } else { return Urls.realmRegisterAction(baseURI, realm.getId()).toString(); } diff --git a/forms/src/main/resources/META-INF/resources/forms/theme/default/register.xhtml b/forms/src/main/resources/META-INF/resources/forms/theme/default/register.xhtml index 0078271801..ca9d8b6745 100755 --- a/forms/src/main/resources/META-INF/resources/forms/theme/default/register.xhtml +++ b/forms/src/main/resources/META-INF/resources/forms/theme/default/register.xhtml @@ -39,6 +39,8 @@ -

#{messages.alreadyHaveAccount} #{messages.logIn}.

+ +

#{messages.alreadyHaveAccount} #{messages.logIn}.

+
\ No newline at end of file diff --git a/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login.xhtml b/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login.xhtml index 05ee4fb803..e99a442c26 100644 --- a/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login.xhtml +++ b/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login.xhtml @@ -39,12 +39,12 @@ body { - +