zaten
org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint
Bahar için sınıf var önyükleme ayrıca bir
içerir tanımladığınız güvenlik yapılandırmanızdaki Yani
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="example",
error="invalid_token",
error_description="The access token expired"
ve sınıf fasulye autowire:
org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint
ve ayarlanması gerekir 401 responses requires that header WWW-Authenticate olarak uyumlu spec kullanmak geliştirici gerektiren hem faydaları, örnek 401 yanıt olabilir
Yani bahar çizme uygulaması ile örneğin:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
@Bean
public Http401AuthenticationEntryPoint securityException401EntryPoint(){
return new Http401AuthenticationEntryPoint("Bearer realm=\"webrealm\"");
}
@Autowired
private Http401AuthenticationEntryPoint authEntrypoint;
...
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/login").anonymous()
.antMatchers("/").anonymous()
.antMatchers("/api/**").authenticated()
.and()
.csrf()
.disable()
.headers()
.frameOptions().disable()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.logout()
.permitAll()
.exceptionHandling().authenticationEntryPoint(authEntrypoint);
}
ilgili çizgidir:
.exceptionHandling().authenticationEntryPoint(authEntrypoint);
Bu çalışıyor! Teşekkür ederim. – Mati
Tanklar, bu çözüm benim de sorunum için çalıştı! Bunun tersini yapmak istedim: 401 ile 403 arasında değişiklik yapmak istiyorum. kimlik doğrulaması dikiş yapıyorEntryPoint httpBasic() öğesine taşındı, bunun için bir düzenleme istedim. – switch87