maven - Spring security *always* redirects to login form -


i'm having webapp spring-security 3.1.0 enabled works fine locally using.

mvn jetty:run 

when deployed remotely on jetty (behind nginx on port 80) spring-security stops working together. is, rest of webapp works except parts secured.


the problem

when navigate secured location redirected login page part works. problem when submitting login form nothing seems happen. come login form nothing has happened.

when try log events, spring-security silent. might clue...

log4j.appender.stdout = org.apache.log4j.consoleappender log4j.appender.stdout.target = system.out log4j.appender.stdout.layout = org.apache.log4j.patternlayout log4j.appender.stdout.layout.conversionpattern = %-5p %d [%t][%f:%l] : %m%n log4j.rootlogger = info, stdout log4j.logger.org.springframework.security=debug 

the thing can think of that's different local setup fact on remote server nginx sits in front of jetty.

does have clue might going wrong here?

here relevant parts of configurations.

nginx

location /test-app {     proxy_set_header host $host;     proxy_set_header x-real-ip $remote_addr;     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_pass http://localhost:8080/test-app; } 

web.xml (spring-security)

<listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener>  <filter>     <filter-name>springsecurityfilterchain</filter-name>     <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class> </filter>  <filter-mapping>     <filter-name>springsecurityfilterchain</filter-name>     <url-pattern>/*</url-pattern> </filter-mapping> 

spring-security.xml

<beans:beans xmlns="http://www.springframework.org/schema/security"         xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xsi:schemalocation="http://www.springframework.org/schema/beans            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd            http://www.springframework.org/schema/security            http://www.springframework.org/schema/security/spring-security-3.1.xsd">          <authentication-manager alias="authenticationmanager">                 <authentication-provider>                         <user-service>                                 <user name="test" password="test" authorities="role_user, role_admin" />                         </user-service>                 </authentication-provider>         </authentication-manager>          <http auto-config="true">                 <intercept-url pattern="/secured/login*" access="is_authenticated_anonymously" />                 <intercept-url pattern="/secured/**" access="role_user" />                  <form-login login-page="/secured/login" login-processing-url="/secured/login/auth"                         authentication-failure-url="/secured/login?error=badcredentials"                         username-parameter="username" password-parameter="password"                         default-target-url="/secured" />                  <logout logout-url="/secured/logout" logout-success-url="/secured" />         </http> </beans:beans> 

is working if connect remote jetty directly using port 8080?

if is, problem related nginx.

when spring security auth succeeds, should able set cookie on browser via set-cookie header in response. maybe nginx has trouble that.

you debug using traffic chrome, press f12 , open network tab. go login page , try login. should able see cookie jsessionid in cookies tab if succeeds.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -