2013-02-28 63 views
2

我将Spring安全性添加到内部网站。我被要求将认证绑定到tomcat-users.xml,以便我们可以减少要更改/记住的密码数量。与Apache Tomcat绑定的Spring安全性tomcat-users.xml UserDatabaseRealm

从我已经能够谷歌了,这是不是很直接,如果可能的话。

事情工作正常,现在,在springSecurity.xml中用户+角色硬编码。

+0

Unrealated。考虑从属性文件载入用户,如[在此解释](http://static.springsource.org/spring-security/site/docs/3.2.x/reference/springsecurity-single.html#core-services-in-memory-服务)。 – 2013-02-28 15:56:25

回答

1

您可以将容器安全性视为pre-authenticated scenario。使用此方法的代码库中有sample app。它使用显式bean配置,但也有可用的<jee> namespace element

+0

该示例已移至:https://github.com/spring-projects/spring-security/tree/master/samples/preauth-xml – Ralph 2016-03-02 20:53:19

0

这可以作为卢克指示的预验证方案完成,但我不建议这种选择。在使用Tomcat xml文件时,您正在使用MemoryRealm,但是您可以切换到JDBCRealm并将两个用户(Spring和Tomcat)存储在数据库中。我建议维护,一致性和安全性。如果您更改servlet容器,则必须迁移安全用户和角色。

https://tomcat.apache.org/tomcat-8.0-doc/realm-howto.html#MemoryRealm