警告:编码后的密码看起来不像 BCrypt
WARNING: Encoded password does not look like BCrypt
控制器class方法:
@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="a$hbxecwitQQ.dDT4JOFzQAulNySFwEpaFLw38jda6Td.Y/cOiRzDFu"
authorities="ROLE_ADMIN" />
</user-service>
评论
admin@123相当于$2a$10$hbxecwitQQ.dDT4JOFzQAulNySFwEpaFLw38jda6Td.Y/cOiRzDFu这个编码密码。
因此,在密码文本中输入 admin@123.
class 用于转换编码值
BCryptPasswordEncoder b=new BCryptPasswordEncoder();
String str=b.encode("admin@123");
System.out.println("Encoding "+str);
正在生成编码值。
控制器class方法:
@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="a$hbxecwitQQ.dDT4JOFzQAulNySFwEpaFLw38jda6Td.Y/cOiRzDFu"
authorities="ROLE_ADMIN" />
</user-service>
评论
admin@123相当于$2a$10$hbxecwitQQ.dDT4JOFzQAulNySFwEpaFLw38jda6Td.Y/cOiRzDFu这个编码密码。 因此,在密码文本中输入 admin@123.
class 用于转换编码值
BCryptPasswordEncoder b=new BCryptPasswordEncoder();
String str=b.encode("admin@123");
System.out.println("Encoding "+str);
正在生成编码值。