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

存储密码时使用安全 Hash 算法并加盐 #74

Closed
Chenrt-ggx opened this issue May 25, 2023 · 1 comment
Closed

存储密码时使用安全 Hash 算法并加盐 #74

Chenrt-ggx opened this issue May 25, 2023 · 1 comment

Comments

@Chenrt-ggx
Copy link

Chenrt-ggx commented May 25, 2023

目前,symphony 在数据库中存储用户密码的 MD5,相关代码如下:

final JSONObject user = new JSONObject();
user.put(User.USER_NAME, userName);
user.put(User.USER_EMAIL, email);
user.put(User.USER_PASSWORD, DigestUtils.md5Hex(password));
user.put(UserExt.USER_APP_ROLE, appRole);
user.put(UserExt.USER_STATUS, UserExt.USER_STATUS_C_VALID);

早在十余年前,MD5 已被证实不安全。因而,建议更新 Hash 算法并检查是否存在其它算法问题,一些供参考的算法如下:

  • 非对称加密算法:RSA2048 (国际) 、SM2(国内)。
  • 对称加密算法:AES256 (国际) 、SM4 (国内)。
  • Hash 算法:SHA256 (国际) 、SM3 (国内)。

此外,在存储密码时,需要加盐后进行 Hash,保证即使攻击者获取了数据库中的密码,也无法在短时间内破译以实现任意用户登录,相关实现可以参考 SpringSecurity 中的 BCryptPasswordEncoder。

@88250
Copy link
Owner

88250 commented May 25, 2023

感谢反馈,的确有这个问题。但是这部分涉及到已有数据迁移,所以已经不太可能进行改造了,建议使用该项目时自行改造,这个稍后会在 README 中说明。

88250 added a commit that referenced this issue May 25, 2023
88250 added a commit that referenced this issue May 25, 2023
@88250 88250 closed this as completed May 26, 2023
88250 added a commit that referenced this issue May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants