我剛纔已與此掙扎了幾天,結束了做以下的普通的Grails 2.4.4項目:
grails create-app
grails install-templates
然後修改BuildConfig.groovy
dependencies {
...
compile "com.google.guava:guava:18.0"
compile "com.github.dblock.waffle:waffle-jna:1.7.3"
compile "net.java.dev.jna:jna:4.1.0"
compile "net.java.dev.jna:jna-platform:4.1.0"
compile "org.slf4j:slf4j-api:1.7.9"
....
}
我然後創建的context.xml下面 .. \ META-INF具有以下內容:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE Context>
<Context>
<Valve className="waffle.apache.NegotiateAuthenticator" principalFormat="fqn" roleFormat="both" protocols="Negotiate,NTLM" />
<Realm className="waffle.apache.WindowsRealm" />
</Context>
,然後添加以下到.. \模板\的web.xml文件:
<display-name>/@[email protected]</display-name>
<security-constraint>
<display-name>Waffle Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Everyone</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>Everyone</role-name>
</security-role>
....
....
爲了驗證其實際工作,我添加一行index.gsp中
<p>You are logged in as remote user <b>${request.getRemoteUser()}</b> in session <b>${session.getId()}</b>.</p>
我測試這個Tomcat的7.0.57下,不得不添加一些罐子TH e Tomcat lib讓我工作。我加了slf4j-api-1.7.9.jar,guava-18.0.jar,jna-platform-4.1.0.jar,jna-4.1.0.jar,waffle-tomcat7-1.7.3.jar,waffle-jna -1.7.3.jar。仍然想知道爲什麼在將相同的罐子添加到BuildConfig.groovy時實際上有必要這樣做。
您是否嘗試過使用DSL向您的grails-app/conf/spring/resources.groovy添加bean聲明? – Gregg 2013-02-22 01:43:13
以下提供的鏈接,您不需要添加任何額外的過濾器。只需配置Spring Security,可以使用標準的Spring Security插件 – 2013-02-22 05:11:10
@IgorArtamonov今天下午我將嘗試這種方法。我會回報。謝謝 – Omnipresent 2013-02-22 14:56:35