2013-02-28 76 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