2016-08-12 3 views
3
나는 봄 부팅, 봄 보안 및 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

프로젝트 코드입니다. 우리에게 잘 작동합니다. 한 번 해봐.

보안 구성 :

@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