I'm developing a Spring application with Spring Security module. The basic settings work pretty fine, but when I want to make some logic like "The FormLogin page is the only one allowed to any people, all the other one can be seen only if the user is authenticated. So my spring config file is like:
<security:http security="none" pattern="/resources/**" />
<security:http security="none" pattern="/FormLogin" />
<security:http auto-config="true" use-expressions="true">
<security:csrf disabled="true" />
<security:intercept-url pattern="/**"
access="isAuthenticated()" />
<security:intercept-url pattern="/admin/**"
access="hasRole('Admin')" />
<security:logout logout-success-url="/welcome"
logout-url="/logout" />
<security:form-login login-page="/FormLogin"
login-processing-url="/j_spring_security_check" default-target-url="/welcome"
username-parameter="username" password-parameter="hashPwd"
authentication-failure-url="/loginError" />
</security:http>
So basically I have my admin folder reserved to the admins, the FormLogin that can be accessed by anybody and all the other pages that can be seen only by authenticated users.
Without this line:
<security:intercept-url pattern="/**" access="isAuthenticated()" />
after the login I got correctly redirected to the welcome page, like this I get redirected to the root of the application and I get the following message:
22/06/2015 20:44:50 - DEBUG - (AbstractSecurityInterceptor.java:242) - Authorization successful
22/06/2015 20:44:50 - DEBUG - (AbstractSecurityInterceptor.java:255) - RunAsManager did not change Authentication object
22/06/2015 20:44:50 - DEBUG - (FilterChainProxy.java:309) - / reached end of additional filter chain; proceeding with original chain
22/06/2015 20:44:50 - DEBUG - (DispatcherServlet.java:861) - DispatcherServlet with name 'spring-mvc' processing GET request for [/Fantacalcio/]
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:294) - Looking up handler method for path /
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:302) - Did not find handler method for [/]
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:294) - Looking up handler method for path /
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:302) - Did not find handler method for [/]
22/06/2015 20:44:50 - DEBUG - (AbstractUrlHandlerMapping.java:123) - Mapping [/] to HandlerExecutionChain with handler [org.springframework.web.servlet.mvc.ParameterizableViewController@92464f] and 1 interceptor
22/06/2015 20:44:50 - DEBUG - (DispatcherServlet.java:947) - Last-Modified value for [/Fantacalcio/] is: -1
22/06/2015 20:44:50 - DEBUG - (DispatcherServlet.java:1241) - Rendering view [org.springframework.web.servlet.view.JstlView: name 'FormLogin'; URL [/WEB-INF/views/FormLogin.jsp]] in DispatcherServlet with name 'spring-mvc'
22/06/2015 20:44:50 - DEBUG - (InternalResourceView.java:166) - Forwarding to resource [/WEB-INF/views/FormLogin.jsp] in InternalResourceView 'FormLogin'
22/06/2015 20:44:50 - DEBUG - (FrameworkServlet.java:996) - Successfully completed request
22/06/2015 20:44:50 - DEBUG - (ExceptionTranslationFilter.java:116) - Chain processed normally
22/06/2015 20:44:50 - DEBUG - (SecurityContextPersistenceFilter.java:105) - SecurityContextHolder now cleared, as request processing completed
What am I doing wrong?