OSBI / saiku

Saiku Analytics - The Worlds Greatest Open Source OLAP Browser
http://community.meteorite.bi
Apache License 2.0
1.31k stars 663 forks source link

Added ability to inject PasswordEncoder into JdbcUserDAO #689

Closed kynx closed 5 years ago

kynx commented 5 years ago

This PR addresses #685. It adds the ability to inject an alternate password encoder to use when hashing user passwords, and adds an implementation that checks if the existing password looks like it's been BCrypt-ed before hashing it. The latter is not the default.

Initially I considered passing an extra parameter to the REST endpoint to indicate this was the desired behaviour. But there's a few problems with that: a lot more files to change, and always the chance some idiot would use it with an un-hashed password.

This approach also opens up the possibility of injecting a DelegatingPasswordEncoder if / when you upgrade to spring security 5, which at first glance might provide a more elegant solution.

To wire in the NoReHashPasswordEncoder, edit saiku-beans.xml:

    <bean id="passwordEncoderBean" class="org.saiku.security.NoReHashPasswordEncoder"/>

    <bean id="userDAO" class="org.saiku.database.JdbcUserDAO">
        <property name="dataSource" ref="userDaoDataSource" />
        <property name="passwordEncoder" ref="passwordEncoderBean" />
    </bean>