gpt4 book ai didi

java - 警告 : Encoded password does not look like BCrypt

转载 作者:太空宇宙 更新时间:2023-11-04 10:06:48 33 4
gpt4 key购买 nike

Controller 类方法:

@RequestMapping(value = "/admin", method = RequestMethod.GET)
public String adminPage() {
return "privatePage";

Spring 安全配置:

<http auto-config="true">
<intercept-url pattern="/admin"
access="hasRole('ROLE_ADMIN')" />
</http>
<authentication-manager>
<authentication-provider>
<password-encoder ref="bCryptPasswordEncoder" />
<user-service>
<user name="admin" password="passwordEncoder.encode(123456)"
authorities="hasRole(ROLE_ADMIN,ROLE_USER)" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="bCryptPasswordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
<beans:constructor-arg value="10" />
</beans:bean>

错误:

Your login attempt was not successful, try again.

原因:凭据错误。

感谢任何回应。

最佳答案

解决方案

<user-service>
<user name="admin" password="$2a$10$hbxecwitQQ.dDT4JOFzQAulNySFwEpaFLw38jda6Td.Y/cOiRzDFu"
authorities="ROLE_ADMIN" />
</user-service>

评论

admin@123 相当于 $2a$10$hbxecwitQQ.dDT4JOFzQAulNySFwEpaFLw38jda6Td.Y/cOiRzDFu 此编码密码。因此,在密码文本中输入 admin@123。

用于转换编码值的类

BCryptPasswordEncoder b=new BCryptPasswordEncoder();
String str=b.encode("admin@123");
System.out.println("Encoding "+str);

生成编码值。

关于java - 警告 : Encoded password does not look like BCrypt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52811223/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com