Integrating spring security in a web application which uses angularjs for routing

时间:2015-06-26 10:15:14

标签: angularjs spring-security

My Web application uses angular routing .The problem which i face on spring security integration is, once the security XML file is in to action it doesn't prevent the intercept url's specified. Please give a solution.

spring security xml:

    <http auto-config="true">
    <intercept-url pattern="/admin**" access="ROLE_USER" /> 

    <form-login 
        login-page="/rest/testing/login" 
        authentication-failure-url="/rest/testing/login?error" 
        username-parameter="username"
        password-parameter="password" />
    <logout logout-success-url="/rest/testing/login"  />
    <!-- enable csrf protection -->
    <csrf/>
</http>

<authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="admin" password="admin" authorities="ROLE_USER" />
        </user-service>
    </authentication-provider>
</authentication-manager>

Angular routing:

  XmlView.config(function($routeProvider)
   {$routeProvider

    // route for the home page
    .when('/', {
        templateUrl : 'transform.jsp',
        controller : 'ViewController'
    })

    // route for the search page
    .when('/search', {
        templateUrl : 'search.jsp',
        controller : 'SearchController'
    })

    // route for the about page
    .when('/admin', {
        templateUrl : 'audits.jsp',
        controller : 'AuditController'
    })

    .when('/login', {
        templateUrl : 'login.jsp',

    })

In the above js file '/admin' url pattern is not intercepted by spring security xml

0 个答案:

没有答案