2016-06-02 2 views
1

스프링 부트 프로젝트에 "spring-boot-starter-actuator"의존성을 추가했습니다.spring-boot 액츄에이터와 스프링 보안 및 폼 기본 인증

프로젝트에 이미 폼 기반 보안이 있습니다.

응용 프로그램의 루트 컨텍스트는 "/"입니다.

관리 : 컨텍스트 경로 : 민감하지 않은 액츄에이터가 작동/액츄에이터

같은

난 application.yaml 추가하여 컨텍스트 루트 "/ 액츄에이터"에서 액추에이터를 추가 한 "건강"으로.

민감한 액추에이터에 액세스하려고하면 사용자 이름/암호에 대한 팝업이 나타납니다. 인증이 수행되지만 "403"액세스가 거부되었습니다. 여기

웹 보안을위한 구성입니다 : application.properties 또는 application.yml의 값 이하로 추가 한 후 팝업은 사용자 이름과 암호를 요청할 때이 자격 증명을 제공

@Configuration 
@EnableWebSecurity 
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) 
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 
private AuthenticationLookupService authenticationLookupService; 
private AuthenticationManagerBuilder authenticationManagerBuilder; 
private UrlSuccessAuthenticationHandler successHandler; 

@Autowired 
public void setAuthenticationLookupService(AuthenticationLookupService authenticationLookupService) { 
    this.authenticationLookupService = authenticationLookupService; 
} 

@Autowired 
public void configureGlobal(AuthenticationManagerBuilder auth) { 
    this.authenticationManagerBuilder = auth; 
} 

@Autowired 
public void setSuccessHandler(UrlSuccessAuthenticationHandler successHandler) { 
    this.successHandler = successHandler; 
} 

@Override 
protected void configure(HttpSecurity http) throws Exception { 
    http.authorizeRequests() 
      .antMatchers("/", "/index.html", "/auth/**").permitAll() 
      .anyRequest().authenticated() 
      .and() 
      .formLogin() 
      .loginPage("/index.html").successHandler(successHandler) 
      .permitAll() 
      .and() 
      .logout() 
      .permitAll(); 

    http.csrf().disable(); // todo: fix later 
} 

@PostConstruct 
public void process() throws Exception { 
    this.authenticationManagerBuilder.userDetailsService(this.authenticationLookupService).passwordEncoder(new ShaPasswordEncoder()); 
} 

}

답변

1

security.user.name=admin 
security.user.password=secret 

엑츄에이터가 민감한 사람에게 액세스하려면 ADMIN 역할 사용자가 필요하기 때문에 해당 사용자의 역할이 ADMIN인지 확인하려면 값을 제공하십시오. 종점.

업데이트 당신이 봄 부팅 1.5을 사용하는 경우. * + 다음 사용자가 ACTUATOR 역할

+0

가 있어야 내가 ADMIN 역할에 대한 부분 만이 여기에 실제로 관련라고 생각합니다. – Nikem

+0

@Nikem 사용자가 액추에이터 값을 특정 자격 증명으로 만 액세스하려는 경우 내 대답에서 말한 접근 방식을 사용하여 제한 할 수 있습니다 – rajadilipkolli

관련 문제