2016-11-06 2 views

答えて

1

あなたbuild.gradle次の依存関係に追加します。

compile("org.springframework.boot:spring-boot-starter-security") 

また例のように春のセキュリティ設定を追加する必要があります。

@Configuration 
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { 

    @Autowired 
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 
     auth 
       .inMemoryAuthentication() 
       .withUser("admin").password("admin").roles("ADMIN", "USER") 
       .and().withUser("user").password("user").roles("USER"); 
    } 

    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http.authorizeRequests().antMatchers("/", "/index/**").permitAll() 
       .and().authorizeRequests().antMatchers("/login", "logout").permitAll() 
       .and().formLogin().loginPage("/login").defaultSuccessUrl("/").permitAll() 
       .and().logout() 
         .deleteCookies("remove") 
         .invalidateHttpSession(true) 
         .logoutUrl("/logout") 
         .logoutSuccessUrl("/logout-success") 
         .logoutRequestMatcher(new AntPathRequestMatcher("/logout")); 
    } 
} 

Securing a Web Applicationで続きを読みます。

関連する問題