Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I change password's hash algorithm? #270

Open
Regentag opened this issue Dec 14, 2020 · 5 comments
Open

Can I change password's hash algorithm? #270

Regentag opened this issue Dec 14, 2020 · 5 comments
Assignees

Comments

@Regentag
Copy link

Regentag commented Dec 14, 2020

I want to change the hash algorithm of user account password from MD5 to SHA256 or bcrypt.
I tried changing the Hash algorithm in the OpenKM.xml file, but it didn't work well. If the user changes the password, it is saved as MD5 in the DB and cannot log in again.

<security:password-encoder hash="md5"/>

Can I modify the settings to use SHA256 or bcrypt?
OpenKM version is 6.3.9(CE).

@darkman97i
Copy link
Contributor

darkman97i commented Dec 16, 2020

Take a look here

public static void createUser(User user) throws DatabaseException, AccessDeniedException {

Because this is a radical change in the repository will be better to set a configuration parameter to switch between md5 and the new password crypt. Take a look at this class about how to create a new configuration parameter https://github.com/openkm/document-management-system/blob/master/src/main/java/com/openkm/core/Config.java ( use it to switch between md5 -> default and bcrypt )

I suggest something like

import import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

BCryptPasswordEncoder bcrypt = new BCryptPasswordEncoder();
			user.setPassword(bcrypt.encode(user.getPassword()));

@Regentag
Copy link
Author

@darkman97i Thank you for answer.
If so, there is no way to apply it without modifying the source code.

@darkman97i
Copy link
Contributor

No, in the code when you create a new user and set the password must use the right crypt type to store in the database. That happens with all the applications adding or changing password algorithm it means changes in the code ( in this case minimal changes )

@Regentag
Copy link
Author

For personal use, I made a SHA-256 patch for version 6.3.9.
https://github.com/Regentag/openkm_6.3.9ce_sha256

@darkman97i
Copy link
Contributor

We will try to add in the next release ... in future better fork the project and then ask for a pull request from your branch to ours.

@gnujavasergio ask me before working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants