[英]password change in spring-security.xml
我刚接触Spring Security,并拥有一个已部署在Tomcat Server中的第三方war文件。 对应用程序的访问由spring-security.xml控制。
<beans:beans profile="some.profile">
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
我想更改在上述设置中所做的默认密码。 但我也想在此xml中对密码进行加密,以便不将其存储为纯文本。 我用谷歌搜索,但是没有得到与这个问题相匹配的答案。我也不想在数据库中坚持下去,因为这只是一次。
可以通过添加额外的参数“ password-encoder”来使用密码哈希。 有一些在线密码哈希计算器,可用于检索哈希字符串(md5,bcrypt或其他编码方法)md5加密的配置示例:
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="b91cd1a54781790beaa2baf741fa6789" authorities="ROLE_USER" />
</user-service>
<password-encoder ref="passwordEncoder" />
</authentication-provider>
</authentication-manager>
<beans:bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.