cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco SSO with Atlassian Crowd

carbotex
Champ in-the-making
Champ in-the-making
Since I can not figure out how to use the external authentication chain to get Alfresco SSO with Atlassian Crowd, I created a filter based on the code found here http://wiki.alfresco.com/wiki/Central_Authentication_Service_Configuration . The filter detects a valid Crowd cookies, then gets the principal name, then logs the principal into Alfresco with the following code:


        authComponent.setCurrentUser(crowdUser);

        UserTransaction tx = transactionService.getUserTransaction();
        NodeRef homeSpaceRef = null;
        User user;

        try {
            tx.begin();
            user = new User(userName, authService.getCurrentTicket(), personService.getPerson(crowdUser));
            homeSpaceRef = (NodeRef) nodeService.getProperty(personService.getPerson(crowdUser), ContentModel.PROP_HOMEFOLDER);
            if(homeSpaceRef == null) {
                    logger.warn("Home Folder is null for user '" + crowdUser + "', using company_home.");
                    homeSpaceRef = (NodeRef) nodeService.getRootNode(Repository.getStoreRef());
            }
            user.setHomeSpaceId(homeSpaceRef.getId());
            tx.commit();
        } catch (Throwable ex) {
            logger.error(ex);

            try {
                    tx.rollback();
            } catch (Exception ex2) {
                    logger.error("Failed to rollback transaction", ex2);
            }

            if (ex instanceof RuntimeException) {
                    throw (RuntimeException) ex;
            } else {
                    throw new RuntimeException("Failed to set authenticated user", ex);
            }
        }

        httpSess.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user);
   httpSess.setAttribute(LoginBean.LOGIN_EXTERNAL_AUTH, Boolean.TRUE);

        if(req.getRequestURI().endsWith(getLoginPage()) == true) {
            res.sendRedirect(req.getContextPath() + "/faces/jsp/browse/browse.jsp");
            return;
        }
        else {
          fc.doFilter(req, res);
          return;
        }

However, I can't use the same code to log into Alfresco Share. Below is the code to log user into Alfresco Share programmatically, but it requires password.


         UserFactory userFactory = FrameworkHelper.getUserFactory();
         boolean authenticated = userFactory.authenticate(req, userName, "mypassword123!");
         if (authenticated) {
             AuthenticationUtil.login(req, res, userName);
         }


Is there a similar solution to Alfresco Explorer where I can log user into Alfresco Share ONLY with their username?
2 REPLIES 2

carbotex
Champ in-the-making
Champ in-the-making
Any input from Alfresco Engineers?

sjohnsto
Champ in-the-making
Champ in-the-making
I am trying to use the same approach with another authentication system and would appreciate an answer.  Implementing the HTTP filter solution on Alfresco was straight forward.  On Share it is not.