Page 1 of 1

Storing password in broadleaf

Posted: Fri Jan 10, 2014 6:25 am
by ankit90
Hi,
I am using broadleaf 3.0.6 GA.. In demo site when I am trying to change password, In current password field it is taking "password{email}" format ... why we need to put current password like this in that field ? and why broadleaf storing password in that format in db too ?

Thanks,
Ankit

Re: Storing password in broadleaf

Posted: Fri Jan 10, 2014 11:52 am
by phillipuniverse
Broadleaf is salting passwords with the customer username. Because there is no password encoder hooked up by default, this is the functionality of zero password hashing with a salt.

You can change the password encoders with the 'password.admin.encoder' and 'password.site.encoder' properties. For instance, in production-shared.properties:

Code: Select all

password.admin.encoder=org.springframework.security.authentication.encoding.ShaPasswordEncoder
password.site.encoder=org.springframework.security.authentication.encoding.ShaPasswordEncoder


Then obviously you would only see some sort of hash in the database but the hash would be the real user password salted with the email address. Also, you can change the behavior of the password salting in applicationContext-security.xml (and applicationContext-admin-security.xml) by modifying the 'blSaltSource' bean:

Code: Select all

<!--  The BLC Authentication manager.   -->
<sec:authentication-manager alias="blAuthenticationManager">
    <sec:authentication-provider user-service-ref="blUserDetailsService">
        <sec:password-encoder ref="blPasswordEncoder">
            <sec:salt-source ref="blSaltSource" />
        </sec:password-encoder>
    </sec:authentication-provider>
</sec:authentication-manager>

<!-- Configuration for salting user passwords. This configuration will use the 'username' property as the salt, which
    implies that the username cannot change. If you would like to change this property or generate a random salt to store
    on a per-customer basis or if you need to allow users to change their password then you will need to modify this
    configuration and likely provide a custom UserDetailsService. -->
<bean id="blSaltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource">
    <property name="userPropertyToUse" value="username" />
</bean>