Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
Deshabilitar la ventana de inicio de sesión en Spring (Http Basic)

Estoy creando una aplicación simple con un sitio de inicio de sesión. Usé el tipo básico de autorización HTTP, pero el problema es que no sé cómo deshabilitar la ventana emergente que se muestra cada vez que paso credenciales incorrectas o en caso de escribir un sitio de punto final seguro antes de la autenticación.

La interfaz está escrita en JS puro, lanzada sin ningún motor de plantillas. Solo archivos js + html en directorio estático.

La página de autenticación usa Fetch Api para enviar encabezados con credenciales

¿Alguien sabe cómo deshabilitar esta ventana, que se muestra a continuación:

Ventana de inicio de sesión

Aquí está mi clase de configuración de seguridad:

 @Configuration @EnableWebSecurity public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { @Resource private UserDetailsService userDetailsService; @Autowired private CustomLogoutHandler logoutHandler; @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(authProvider()); } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().authorizeRequests() .antMatchers(HttpMethod.POST, "/demo/users/save").permitAll() .antMatchers(HttpMethod.POST, "/demo/users/**").permitAll() .antMatchers(HttpMethod.POST, "/users/*/save").permitAll() .antMatchers(HttpMethod.DELETE, "/users/**").permitAll() .antMatchers(HttpMethod.POST, "/users/*/verify").permitAll() .antMatchers(HttpMethod.GET,"/users/**").permitAll() .antMatchers(HttpMethod.PUT,"/users/**").permitAll() .antMatchers("/css/**", "/js/**", "/img/**").permitAll() .antMatchers("/signup-page.html").permitAll() .antMatchers("/landing-page.html").permitAll() .anyRequest().authenticated() .and() .formLogin() .disable() .logout() .logoutUrl("/logout") .addLogoutHandler(logoutHandler) .logoutSuccessUrl("/landing-page.html") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK)) .permitAll() .and() .httpBasic(); } @Bean public DaoAuthenticationProvider authProvider() { DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); authProvider.setUserDetailsService(userDetailsService); authProvider.setPasswordEncoder(passwordEncoder()); return authProvider; } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No pude encontrar la respuesta antes, cada respuesta que encontré consistía en "deshabilitar httpBasic" y esa no fue una solución satisfactoria. Aquí hay un tema: la seguridad de Spring Boot muestra la ventana emergente Http-Basic-Auth después de un inicio de sesión fallido

y estas líneas resolvieron mi problema:

 httpBasic() .authenticationEntryPoint(new AuthenticationEntryPoint(){ //<< implementing this interface @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { //>>> response.addHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\""); <<< (((REMOVED))) response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase()); } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!