2016-07-14 3 views
0

내 앱에 로그인 기능을 구현 중이며 시스템의 사용자를 담당하는 컨트롤러를 보호하고 싶습니다. 그동안 나는 모든 컨트롤러에서 https를 사용하고 싶지 않습니다. 그것은 가능한가요 아니면 모든 컨트롤러에 대해 http 또는 https를 사용해야합니까?스프링 부트가 포함 된 HTTP 및 Https 컨트롤러

답변

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 
    } 
} 
관련 문제