0

I want to equip my Spring MVC application with authentication. To this end, I use Spring security in the following way:

(EDIT: I created a new test project in order to have all configuration in one place)

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans ...>
    <annotation-driven />
    <resources mapping="/resources/**" location="/resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <sec:http auto-config='true'>
        <sec:intercept-url pattern="/**" access="ROLE_USER" />
    </sec:http>
    <sec:authentication-manager>
        <sec:authentication-provider>
            <sec:user-service>
                <sec:user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" />
                <sec:user name="bob" password="bobspassword" authorities="ROLE_USER" />
            </sec:user-service>
        </sec:authentication-provider>
    </sec:authentication-manager>

    <context:component-scan base-package="de.emundo.project" />

</beans:beans>

If I request any page from the deployed server, no login redirection is undertaken. It is as if spring-security.xml was not included, at all (which it is, obviously).

Am I missing something here?

Bastian
  • 4,638
  • 6
  • 36
  • 55
  • Have you declared the filter in your web.xml? – M. Deinum Dec 22 '14 at 09:06
  • @M.Deinum I just created a new test project to simplify the structure a bit. Please have a look at the updated code listing. – Bastian Dec 22 '14 at 09:55
  • 1
    As stated before have you added the necessary filter to the web.xml. You can have 1000 of lines of configuration but if there is no filter applying the security those lines are useless. So in short add your web.xml.. – M. Deinum Dec 22 '14 at 09:56
  • @M.Deinum That was the problem - I forgot to add the filter to web.xml. Now at least I get an error message: http://stackoverflow.com/questions/27600899/spring-security-no-bean-named-springsecurityfilterchain-is-defined – Bastian Dec 22 '14 at 10:34

0 Answers0