2016-07-14 2 views
0

私は自分のアプリでログイン機能を実装しています。私はシステム内のユーザを担当するコントローラを保護したいと思います。その間、私はすべてのコントローラでhttpsを使いたくありません。それはある方法で可能ですか、またはすべてのコントローラにhttpまたはhttpsを使用する必要がありますか?HttpとHttpsの春のブートを伴うcontollers

答えて

0

私はJavaでSpringを設定しませんが、ほぼ100%はそのようにすることができます。

@Configuration 
@EnableWebMvcSecurity 
public class SecurityConfig extends WebSecurityConfigurerAdapter { 

    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http 
      .authorizeRequests() 
      .antMatchers("/secure").hasRole("USER") 
      .antMatchers("/supersecure").hasRole("USER") 
      .anyRequest().permitAll(); 
      .and() 
      .requiresChannel() 
      .antMatchers("/supersecure").requiresSecure(); //at this part you set up https 
    } 
} 
関連する問題