8 Replies Latest reply on Dec 2, 2008 7:00 AM by psevestre

    Page restricted to unauthenticated users ?

      Hi,

      i'd like to have a "welcome" page that would be displayed only for unauthenticated users, so when they login, they don't see this page anymore.

      Does a Unauthenticated role exists that i could you to configure the page <security-constraint> so that only unauthenticated users would see the page ?

      Thanks for your help.

        • 1. Re: Page restricted to unauthenticated users ?
          sannegrinovero

          Did you find out how to do this?

          I would like to have the same effect; Using a custom portlet would do the trick, but I would loose the capability to update the welcome pages by using CMS.

          • 2. Re: Page restricted to unauthenticated users ?
            dkrieger

            We came across this very same problem. We made modifications to the User Authentication system by setting a "Guest" role when not logged in.

            The changes were in the 2.6 branch but changes have been made since then to how authentication is handled. What version of portal are you using?

            • 3. Re: Page restricted to unauthenticated users ?
              sannegrinovero

               

              The changes were in the 2.6 branch but changes have been made since then to how authentication is handled. What version of portal are you using?

              I'm using 2.7.0.GA;
              are you referring to some patch committed to the 2.6 branch or something you did on your local sources?

              • 4. Re: Page restricted to unauthenticated users ?
                dkrieger

                No, local change I made to 2.6. It was sort of a hack so wasn't really worthy of committing. I tried doing the same to the 2.7 code but things have changed a bit so its not working like I'd hoped. If I get it working I'll be happy to share the code.

                • 5. Re: Page restricted to unauthenticated users ?
                  dkrieger

                  Okay so the same fix did work in 2.7... just missed an important line along the way.

                  Here is the diff file from the 2.7 svn branch that should add support:
                  http://codingislife.com/share/jbp/guest/JBossPortalGuestRolePatch.diff

                  If you don't feel like recompiling I also have the portal-security-lib.jar:
                  http://codingislife.com/share/jbp/guest/portal-security-lib.jar


                  With this, the role name "Guest" should be active when a person is not logged in. Here is an example of the deployment xml from portlet-instances.xml:

                  <deployment>
                   <if-exists>overwrite</if-exists>
                   <instance>
                   <instance-id>GuestPortletInstance</instance-id>
                   <portlet-ref>TestPortlet</portlet-ref>
                   <security-constraint>
                   <policy-permission>
                   <action-name>view</action-name>
                   <role-name>Guest</role-name>
                   </policy-permission>
                   </security-constraint>
                   </instance>
                   </deployment>
                  


                  I didn't try it with page security (as in an -object.xml) but I'd imagine it should work the same.

                  • 6. Re: Page restricted to unauthenticated users ?
                    psevestre

                    I had a similar problem, but I've used a different approach.

                    In my case, I want to keep the page (it's the default page) but some elements should not appear to logged users.

                    To achieve this, I've used some logic in my layout pages, rendering a given region - or not - based on the return value of request.getRemoteUser().

                    Something like this:

                    <% if ( request.getRemoteUser() == null ) { %>
                    <p:region regionName='welcomebox' regionID='welcomebox'/>
                    <% } %>
                    








                    • 7. Re: Page restricted to unauthenticated users ?
                      sannegrinovero

                      thanks a lot; I had it done as in psevestre's code, but will definitely try the patch of dkrieger as it permits my users to manage the front page by CMS.

                      I wonder if this functionality wouldn't be welcome by more users, or if it's not possible because of some spec. A configurable option maybe?

                      • 8. Re: Page restricted to unauthenticated users ?
                        psevestre

                        Just a sidenote: using "conditional regions" as I did also supports content management via the admin portal. All you have to do is create multiple regions and, in your layout pages, add the appropriate logic.

                        The end-user will see all regions, and will be able to add content to them at will. Using sound region names like "anonymous_banner" or "admin_sidebox" is a good idea, too.