2014-06-08 4 views
0

예제 앱을 기반으로 스프링 부트 - 보안 프로젝트를 만들었지 만 나머지 컨트롤러는 제대로 작동하지만 나머지 리소스에 액세스 할 수는 있지만 보안 기능이 전혀 작동하지 않는 것 같습니다 그래서 아래 명시된 바와 같이 중단 점을 추가하면 중단되지 않습니다. 이유를 모르겠다.스프링 보안 - 인증이 작동하지 않음

@Configuration 
@EnableWebSecurity 
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { 

    @Override 
    protected void configure(AuthenticationManagerBuilder auth) throws Exception { 
     // @formatter:off 
     auth.inMemoryAuthentication() // breakpoint here 
      .withUser("roy") 
       .password("spring") 
       .roles("ADMIN"); 
     // @formatter:on 
    } 

    @Override 
    @Bean 
    public AuthenticationManager authenticationManagerBean() throws Exception { 
     return super.authenticationManagerBean(); 
    } 

} 

여기 Codio와 호스팅 및 편집 가능한 전체 프로젝트입니다 : http://bit.ly/1uFI0t5

+0

@EnableAutoConfiguration 주석을 추가하십시오. –

+0

그래, 내가 그 – xybrek

답변

0

당신은 그것을 보호해야하는 URL이있는 프레임 워크를 얘기해야합니다.

@Configuration 
@EnableWebSecurity 
public class SecurityConfig extends WebSecurityConfigurerAdapter { 

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

    @Override 
    protected void configure(HttpSecurity http) throws Exception { 

     http.authorizeRequests() 
      .antMatchers("/**").access("hasRole('ROLE_USER')") 
      .and().formLogin(); 

    } 
} 
+0

예 ResourceServerConfiguration OAuth2ServerConfiguration – xybrek

+0

BTW, 내가 복사 한 원본 여기에서 https://github.com/royclarkson/spring-rest-service-oauth – xybrek

+0

이이 문제가 있습니다. formLogin()을 해결할 수 없습니다. – xybrek

관련 문제