2016-08-12 104 views
3

我与教程,介绍如何编写使用Spring启动,春季安全和AngularJS春季启动与退出Angularjs错误

https://github.com/spring-guides/tut-spring-security-and-angular-js/tree/master/oauth2-vanilla

,该项目

模块化项目单页的应用程序工作

https://github.com/sharmaritesh/spring-angularjs-oauth2-sample

我无法注销当前登录的用户。 如果您单击“注销”链接,您将看到主页更改(不再显示问候语),因此用户不再使用UI服务器进行身份验证。虽然点击“登录”,但实际上并不需要通过授权服务器中的认证和批准周期(因为您尚未注销)。

我是Spring的新手,希望有些用户可以注销,然后再回到登录页面。 请有人可以帮助我或提出一些建议来解决这个问题?

回答

0

这是我们的项目code.its正常工作。试试这一次。

安全配置:

@Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http.httpBasic().and().authorizeRequests().antMatchers("/public/**") 
       .permitAll().antMatchers("/admin/**").hasAuthority("admin") 
       .antMatchers("/user/**").hasAuthority("user") 
       .and() 
       .logout() 
       // Logout requires form submit. Bypassing the same. 
       .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) 
       .logoutSuccessUrl("/index.html").and() 
       .addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class) 
       .csrf().disable();/* 
           * requireCsrfProtectionMatcher(new 
           * CsrfRequestMatcher()) 
           * .csrfTokenRepository(csrfTokenRepository()); 
           */ 

    } 

angularjs:

$scope.logout = function() { 
       $http.get('/logout').then(function() { 

        $location.url('/'); 
       }) 
      } 

路由:

app.config([ '$routeProvider', function($routeProvider) { 

    $routeProvider.when('/admin', { 
     templateUrl : 'admin.html', 

    }).when('/dashboard', { 
     templateUrl : 'dashboard.html' 
    }).when('/preferences', { 
     templateUrl : 'preferences.html', 
    }).otherwise('/', { 
     templateUrl : 'index.html', 
    }) 
} ]); 
+0

喂纳雷什vadlakonda, 感谢您的回答,我尝试使用,但心不是解决我的问题。 请你尝试在github代码链接中使用,我把我的问题描述? 谢谢 – user2657234