如何轻松禁用谷歌Chrome登录弹窗?Spring Security配置求助
求助:隐藏弹窗的简短代码/关键词

之前有人给我展示过一段非常简短的代码可以隐藏这个弹窗,但我忘了具体是什么代码,也没保存在电脑里。有没有人知道这段简短的代码/关键词是什么?
我已经尝试过以下操作,但都没效果:
- 修改SecurityConfig,设置
csrf().disable() - 修改前端UserContext中的UseEffect:
useEffect(() => { if (!userContext.isAuthenticated) { navigate('/login'); } }, []);
但我觉得这个问题得靠后端解决,求各位帮忙。
以下是我的SecurityConfig代码:
@EnableWebSecurity @Configuration public class SecurityConfig { @Bean public PasswordEncoder passwordEncoder() { return Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8(); } @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { CsrfTokenRequestAttributeHandler requestHandler = new CsrfTokenRequestAttributeHandler(); requestHandler.setCsrfRequestAttributeName(null); String organizationPath = "/api/organization/**"; return http .csrf(csrf -> csrf .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .csrfTokenRequestHandler(requestHandler)) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)) .httpBasic().and() .authorizeHttpRequests() .requestMatchers(HttpMethod.DELETE, organizationPath).hasRole(Role.ADMIN.toString()) .requestMatchers(HttpMethod.POST, organizationPath).hasRole(Role.ADMIN.toString()) .requestMatchers(HttpMethod.PUT, organizationPath).hasRole(Role.ADMIN.toString()) .requestMatchers(HttpMethod.GET, organizationPath).hasAnyRole("BASIC", "ADMIN") .anyRequest().permitAll() .and().build(); } }
内容的提问来源于stack exchange,提问作者JustRob
相关产品推荐
相关产品推荐

