스프링 보안 자바 설정을 사용하여 웹 애플리케이션을 보호하려고합니다.스프링 보안 자바 설정을 사용하는 동안 기본 인증을 사용하지 않음
이 구성이 모습입니다 : - 내가 명시 적으로 비활성화 HTTP 기본 인증을
@Configuration
@EnableWebMvcSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
private String googleClientSecret;
@Autowired
private CustomUserService customUserService;
/*
* (non-Javadoc)
*
* @see org.springframework.security.config.annotation.web.configuration.
* WebSecurityConfigurerAdapter
* #configure(org.springframework.security.config
* .annotation.web.builders.HttpSecurity)
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/","/static/**", "/resources/**","/resources/public/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.and()
.httpBasic().disable()
.requiresChannel().anyRequest().requiresSecure();
// @formatter:on
super.configure(http);
}
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
// @formatter:off
auth
.eraseCredentials(true)
.userDetailsService(customUserService);
// @formatter:on
super.configure(auth);
}
}
주의 사용 : - 보안 된 액세스하는 동안
.httpBasic().disable()
난 여전히 HTTP Authenticaton 프롬프트 상자를 얻고있다 url. 왜?
제발 도와주세요. 번들로 제공되는 기본 로그인 양식 만 렌더링하려고합니다.
봄 부팅 스타터 버전 : 1.1.5 봄 보안 버전 : 3.2.5
감사
경우
'security.basic.enabled = false'를'application.properties'에 추가하십시오. 또한 오버라이드 된 메소드에서'super.configure'를 호출해서는 안됩니다. –
@ M.Deinum 그걸 고쳤습니다. 하지만 내가 왜 자바 config에서 명시 적으로 비활성화되었을 때 비활성화되지 않았습니까? –
전체 구성에 각각 기여하는 여러 개의 'WebSecurityConfigurer'를 가질 수 있습니다. 그것은 아주 잘 당신은 기본 인증 및 양식과 정상적인 사이트로 보호되는 귀하의 웹 사이트의 나머지 부분을 가지고있을 수 있습니다. 나머지는'WebSecurityConfigurer'를, 폼은 하나씩 2 개의 WebSecurityConfigurer를 만들 수 있습니다. http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-security.html (스프링 부트 참조, 보안 섹션)을 체크 아웃 할 수도 있습니다. –