4 Replies Latest reply on Jul 10, 2013 6:40 AM by tomashuryn

    OAuth & FB - custom registration screen and username

    tomashuryn

      I've made my own integration with FB in the past and I would like to move to GateIn native integration now. And I have two question to FB integration:

       

      1) How can I call my own page/Richfaces popup, when user is login with FB for the first time (registration to the GateIn portal?

      2) How can I modify check algorithm for registration/login discovery - because username in my GateIn instance is email address, not FB username and I need to check, if user email address from FB exists as usernema in GateIn

       

      Many thanks for reply.

        • 1. Re: OAuth & FB - custom registration screen and username
          mposolda

          Hi,

           

          The FB integration is available from GateIn 3.6.0.Final automatically and documented here https://docs.jboss.org/author/display/GTNPORTAL36/OAuth+-+Authentication+with+social+network+accounts . If default GateIn registration screen doesn't suit your needs for some reason, maybe you can do this by:

          - Convert your Richfaces application into portlet and add this portlet to some page (let's assume it's /portal/richfacesRegistration). Page should be likely visible just for members of group /platform/guests (which represents anonymous user in GateIn)

          - Change attribute "registrationUrl" of OAuthAuthenticationFilter in file GATEIN_HOME/gatein/gatein.ear/portal.war/WEB-INF/conf/sso/oauth-configuration.xml to your registration page (/portal/richfacesRegistration)

          - Probably you will also need to comment OAuthLifecycle in GATEIN_HOME/gatein/gatein.ear/portal.war/WEB-INF/webui-configuration.xml (or maybe override the class if you want some custom behaviour. Because this lifecycle also handles displaying of error messages in oauth integration...)

          - In your Richfaces application, you may then need to obtain authenticated user from AuthenticationRegistry from attribute OAuthConstants.ATTRIBUTE_AUTHENTICATED_PORTAL_USER . Once you obtain User object, you can do whatever you want with it. For example you can use email address of this User object to be displayed as username in your registration screen.

           

          But note that email addresses are not permitted as username in GateIn by default (Characters @ and . are not allowed) .

           

          Look for existing GateIn classes for more reference if needed. For example:
          https://github.com/gatein/gatein-portal/blob/master/component/web/oauth-web/src/main/java/org/gatein/security/oauth/web/OAuthAuthenticationFilter.java

           

          If you want some even more custom behaviour, you can possibly override OAuthAuthenticationFilter and configure it in oauth-configuration.xml .

           

          Marek

          • 2. Re: OAuth & FB - custom registration screen and username
            tomashuryn

            Hi Marek,

              thank you for reply, it looks like what I needed.

            • 3. Re: OAuth & FB - custom registration screen and username
              tomashuryn

              Hi, I have one more question. I've modified OAuthLifecycle and OAuthAuthenticationFilter classes. Login process redirects user from facbook to JAAS login proces with right username and fake password - the login fail. I've my own portal container configuration, so probably there is some omited configuration details in my config files. What's wrong or how JAAS authenticate user with fake password?

              • 4. Re: OAuth & FB - custom registration screen and username
                tomashuryn

                It's solved now. I have added this configuration snippet:

                 

                <login-module code="org.gatein.security.oauth.jaas.OAuthLoginModule" flag="required">

                  <module-option name="portalContainerName" value="portal"/>

                  <module-option name="realmName" value="gatein-domain"/>

                </login-module>