cancel
Showing results for 
Search instead for 
Did you mean: 

Authentication

viguan
Champ in-the-making
Champ in-the-making
Hi, I've created a web portal and i need to use the same users that are registrated on the portal in alfresco. The user names and passwords are stored in a table in a sqlserver db. Is it possible to use that users in alfresco using the external authentication subsystem?
Thank you
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Yes you could use External Authentication.  Or you could write an authentication adapter for your database backed user store.  

However would it not be easier to configure a user registry (such as LDAP or AD) that could be used by both Alfresco and your web portal?

vasa99
Champ in-the-making
Champ in-the-making
I was wondering if there is a sample code which helps me in configuring the users from the external database.
We do not have ldap so i want to configure database for authentication

julio_melo
Champ in-the-making
Champ in-the-making
I'm not sure if this is the best solution, but I could achieve something similar with those steps:

(1) You should extend AbstractAuthenticationComponent:


public class MyUserAuthenticationImpl extends AbstractAuthenticationComponent {
        (…)
   @Override
   protected void authenticateImpl(String userName, char[] password) {

      if (!checkUserAndPasswordOnDatabase(userName, password))
         throw new AuthenticationException("Invalid credentials.");

                // Successfully authenticated…
      clearCurrentSecurityContext();
      setCurrentUser(userName);
   }

   private boolean checkUserAndPasswordOnDatabase(String username, char[] password) {
      // TODO: Implement your SQL query here…
   }
}

(2) Register the bean in "alfresco/subsystems/Authentication/myUserAuthentication/myUserAuthentication-context.xml":


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <bean id="authenticationComponent" class="MyUserAuthenticationImpl"
      parent="authenticationComponentBase">
      <property name="nodeService">
         <ref bean="nodeService" />
      </property>
      <property name="personService">
         <ref bean="personService" />
      </property>
      <property name="transactionService">
         <ref bean="transactionService" />
      </property>
   </bean>

   <bean id="localAuthenticationService"
      class="org.alfresco.repo.security.authentication.AuthenticationServiceImpl">
      <property name="ticketComponent">
         <ref bean="ticketComponent" />
      </property>
      <property name="authenticationComponent">
         <ref bean="authenticationComponent" />
      </property>
      <property name="sysAdminParams">
         <ref bean="sysAdminParams" />
      </property>
   </bean>
</beans>

(3) Edit your alfresco-global.properties and define:


authentication.chain=myUserAuthentication1:myUserAuthentication

…where myUserAuthentcation is the same name of that XML path.

lemairea
Champ in-the-making
Champ in-the-making
hi all,
I'm trying to do log against an external database too.
I'm kind of new in Alfresco and I don't understand where I should write the java class to extend the AbstractAuthenticationComponent…
How can I deploy it then ?

thanks,
Antoine