2013-02-26 118 views
1

我正在嘗試使用登錄窗體設置基本的spring-security-ldap身份驗證,但是當我嘗試登錄時,仍然收到一個http基本彈出窗口,不允許登錄。使用彈簧安全禁用基本身份驗證ldap

我的security.xml:

<s:http> 
    <s:intercept-url pattern="/login*" access="ROLE_ANONYMOUS" /> 
    <s:intercept-url pattern="/**/*.html*" access="ROLE_ADMIN,ROLE_USER,ROLE_READONLY" /> 
    <s:form-login login-page="/login.jsp" 
      authentication-failure-url="/login.jsp?error=true" 
      login-processing-url="/j_security_check" 
      default-target-url="/mainMenu.html" 
      always-use-default-target="true" /> 
    <s:logout /> 
</s:http> 

<s:ldap-server url="${ldap.url}" 
      manager-dn="${ldap.adm_username}" 
      manager-password="${ldap.adm_password}"/> 

<s:authentication-manager> 
    <s:ldap-authentication-provider user-search-filter="(cn={0})" 
            user-search-base="${ldap.user_search_base}" 
            group-search-base="ou=myapp,ou=mysystem,o=ACME" 
            role-prefix="none"/> 
</s:authentication-manager> 

從web.xml中:

<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 

    <!-- First filter-mapping in file --> 
<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

這是一個重構的工作的一部分,比較它是如何重構之前部署的版本時,網址(server):(port)/(webapproot)/j_security_check不可用,但在重構後可用,並提示基本登錄框,這也是嘗試通過登錄頁面登錄時彈出的內容。

Login box

當試圖通過登錄框登錄,我得到這個堆棧跟蹤服務器日誌:

[#|2013-02-26T12:41:30.411+0100|WARNING|glassfish3.1|javax.enterprise.system.container.web.com.sun.web.security|_ThreadID=333;_ThreadName=Thread-1;|Exception 
    com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Failed file login for . 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:394) 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:240) 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:153) 
     at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:483) 
     at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:425) 
     at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:176) 
     at org.apache.catalina.authenticator.AuthenticatorBase.processSecurityCheck(AuthenticatorBase.java:909) 
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:487) 
     at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623) 
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 
     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) 
     at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) 
     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) 
     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) 
     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) 
     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) 
     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) 
     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) 
     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
     at com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
     at java.lang.Thread.run(Thread.java:722) 
    Caused by: javax.security.auth.login.LoginException: Failed file login for . 
     at com.sun.enterprise.security.auth.login.FileLoginModule.authenticate(FileLoginModule.java:84) 
     at com.sun.enterprise.security.auth.login.PasswordLoginModule.authenticateUser(PasswordLoginModule.java:117) 
     at com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:148) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:601) 
     at javax.security.auth.login.LoginContext.invoke(LoginContext.java:784) 
     at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203) 
     at javax.security.auth.login.LoginContext$4.run(LoginContext.java:698) 
     at javax.security.auth.login.LoginContext$4.run(LoginContext.java:696) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:695) 
     at javax.security.auth.login.LoginContext.login(LoginContext.java:594) 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:382) 
     ... 29 more 
    |#] 

如何禁用基本登錄,和我是什麼失蹤爲了對LDAP服務器進行身份驗證?

更新:

我改變了GlassFish的安全領域LDAP的境界,並設置它,因爲它是舊的GlassFish服務器上。此外,我禁用了glassfish中的「安全經理」。現在,我仍然得到額外彈出登錄框,但堆棧跟蹤看起來更好:

[#|2013-02-26T13:47:49.640+0100|WARNING|glassfish3.1|javax.enterprise.system.container.web.com.sun.web.security|_ThreadID=90;_ThreadName=Thread-1;|Exception 
    com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Access denied on empty password for user . 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:394) 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:240) 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:153) 
     at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:483) 
     at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:425) 
     at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:176) 
     at org.apache.catalina.authenticator.AuthenticatorBase.processSecurityCheck(AuthenticatorBase.java:909) 
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:487) 
     at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623) 
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 
     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) 
     at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) 
     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) 
     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) 
     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) 
     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) 
     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) 
     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) 
     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
     at com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
     at java.lang.Thread.run(Thread.java:722) 
    Caused by: javax.security.auth.login.LoginException: Access denied on empty password for user . 
     at com.sun.enterprise.security.auth.login.LDAPLoginModule.authenticate(LDAPLoginModule.java:102) 
     at com.sun.enterprise.security.auth.login.PasswordLoginModule.authenticateUser(PasswordLoginModule.java:117) 
     at com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:148) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:601) 
     at javax.security.auth.login.LoginContext.invoke(LoginContext.java:784) 
     at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203) 
     at javax.security.auth.login.LoginContext$4.run(LoginContext.java:698) 
     at javax.security.auth.login.LoginContext$4.run(LoginContext.java:696) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:695) 
     at javax.security.auth.login.LoginContext.login(LoginContext.java:594) 
     at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:382) 
     ... 29 more 
    |#] 

但是我怎麼禁用GlassFish的安全機制都在一起,只依靠一個春天?

更新#2:找到罪魁禍首。

<login-config> 
    <auth-method>BASIC</auth-method> 
</login-config> 

刪除它,並沒有更多的登錄框:)關閉到再下一個問題:我在GlassFish安裝有這個默認-web.xml中p

回答

2

你的基本身份驗證不被處理由Spring Security提供。查看堆棧跟蹤。沒有Spring Security過濾器。它看起來像您的基本身份驗證是由Glassfish本身處理。嘗試通過Glassfish禁用基本身份驗證。你有登錄配置安全限制標籤在web.xml?如果這是真的,那就把它們刪除。

+0

感謝您的回覆,我正在研究glassfish atm(重構還包括移植到更新的glassfish版本),並且在舊服務器中我看到有一個針對我的ldap服務器設置的安全領域,它是不在新的設置中。我會嘗試添加它,看看會發生什麼。 – Tobb 2013-02-26 12:27:03

+0

你在web.xml中有login-config和security-constraint標籤嗎? – 2013-02-26 12:28:49

+0

不在我的項目的web.xml中,沒有。我必須說,我發現在glassfish的安全領域和Spring配置的安全領域之間很難分開,並且試圖從一個相當混亂的項目中學習並不容易。目前我不確定Spring設置或glassfish設置是否提供身份驗證設置.. – Tobb 2013-02-26 12:32:51