2017-01-31 17 views
2

私は残りのAPIを作成してSpring Securityを実装しました。すべて正常に動作しますが、(まだ開発中ですが) localhost:8080/consoleを開きます。 マイコード:H2コンソールとSpring Security - permitAll()が動作しません

@Override 
protected void configure(HttpSecurity http) throws Exception { 
    // allow everyone to register an account; /console is just for testing 
    http.authorizeRequests().antMatchers("/register", "/console").permitAll(); 

    http.authorizeRequests().anyRequest().fullyAuthenticated(); 

    // making H2 console working 
    http.headers().frameOptions().disable(); 

    /* 
    https://docs.spring.io/spring-security/site/docs/current/reference/html/csrf.html#when-to-use-csrf-protection 
    for non-browser APIs there is no need to use csrf protection 
    */ 
    http.csrf().disable(); 
} 

そして、何本当に奇妙である - はlocalhost:8080 /レジスタは、任意の認証を必要とするが、/コンソールに戻りません。

{ 
"timestamp": 1485876313847, 
"status": 403, 
"error": "Forbidden", 
"message": "Access Denied", 
"path": "/console" 
} 

誰もがそれを修正する方法を知っていますか?

答えて

1

私はこれと同様の構成です。それを試すことができますか?

http 
    .authorizeRequests() 
     .antMatchers("/register").permitAll() 
     .and() 
    .authorizeRequests() 
     .antMatchers("/console/**").permitAll(); 
+1

。 http://www.authorizeRequests()。antMatchers( "/ register"、 "/ console/**")。permitAll(); ' – doublemc

0

私はで私の問題を解決する:これは、あまりにもかかわらず)(.authorazieRequestsを倍増する必要が素晴らしい作品なかっ

http.headers().frameOptions().disable(); 
関連する問題