A worthy mention: I follow the tutorial Securing GWT Applications with Spring Security .
I do not understand. I can't permitAll to get permitAll to work the way I need it.
This is my current configuration:
<http auto-config="true"> <intercept-url pattern="/**" access="permitAll" /> <form-login login-page="/login" default-target-url="/welcome" authentication-failure-url="/login?error" username-parameter="username" password-parameter="password" /> </http>
If I access my site at //localhost:8080 , the site becomes not fully loaded because the request
There are 403 Forbidden for some reason. The way I configured Spring Security should not be a problem here, if I understood correctly.
I do not work if just add
<intercept-url pattern="/**" access="permitAll" />
to <http ..> what does adding this do:
<http pattern="/app/xsrf" security="none"/>
I would like to understand why, because this is not how I want to configure Spring Security .. adding every URL that should be allowed.
An additional problem that I encountered is that for some reason (possibly the same), I cannot access //localhost:8080/login . This means that if I send my login to /login , I get 403 Forbidden .
Now you might think that adding <http pattern="/login" security="none"/> will help here, but no. If I add this to my configuration, I get 404 Not Found at this specific URL.
It starts to infuriate me, because I have been stuck here for so many days that I dare not tell you. Your help should be appreciated and rewarded.
The whole applicationContext-service.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" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd"> <beans:import resource="applicationContext-jooq.xml"/> <http pattern="/app/xsrf" security="none"/> <http auto-config="true"> <intercept-url pattern="/**" access="permitAll" /> <form-login login-page="/login" default-target-url="/welcome" authentication-failure-url="/login?error" username-parameter="username" password-parameter="password" /> </http> <beans:bean id="authenticationListener" class="com.mz.server.web.auth.CustomAuthenticationListener"/> <beans:bean id="authenticationProvider" class="com.mz.server.web.auth.CustomAuthenticationProvider"/> <beans:bean id="userDetailsService" class="com.mz.server.web.service.CustomUserDetailsService"/> <authentication-manager alias="authenticationManager"> <authentication-provider ref="authenticationProvider"/> </authentication-manager> <beans:bean id="loginService" class="com.mz.server.web.service.LoginService"> <beans:constructor-arg ref="dslContext" /> </beans:bean> </beans:beans>
Edit:
Reduced applicationContext-service.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-4.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd"> <beans:import resource="applicationContext-jooq.xml"/> <global-method-security pre-post-annotations="enabled"/> <http auto-config="true"> <intercept-url pattern="/**" access="permitAll" /> </http> </beans:beans>
This is web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>GWT Application | mz</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <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> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>com.mz.server.web.ServerConfig</listener-class> </listener> <servlet> <servlet-name>login</servlet-name> <servlet-class>com.mz.server.web.servlet.LoginServletImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>login</servlet-name> <url-pattern>/app/login</url-pattern> </servlet-mapping> <servlet> <servlet-name>xsrf</servlet-name> <servlet-class>com.google.gwt.user.server.rpc.XsrfTokenServiceServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>xsrf</servlet-name> <url-pattern>/app/xsrf</url-pattern> </servlet-mapping> <servlet> <servlet-name>mobile-restapi</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mobile-restapi</servlet-name> <url-pattern>/app/restapi/*</url-pattern> </servlet-mapping> <context-param> <param-name> gwt.xsrf.session_cookie_name </param-name> <param-value> mzsid </param-value> </context-param> <context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath:/**/spring-config.xml classpath*:applicationContext-service.xml </param-value> </context-param> </web-app>