mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	vue2 新增行为验证码
This commit is contained in:
		@@ -81,7 +81,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 配置 URL 的安全配置
 | 
			
		||||
     *
 | 
			
		||||
     * <p>
 | 
			
		||||
     * anyRequest          |   匹配所有请求路径
 | 
			
		||||
     * access              |   SpringEl表达式结果为true时可以访问
 | 
			
		||||
     * anonymous           |   匿名可以访问
 | 
			
		||||
@@ -109,8 +109,8 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap
 | 
			
		||||
                .headers().frameOptions().disable().and()
 | 
			
		||||
                // 一堆自定义的 Spring Security 处理器
 | 
			
		||||
                .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint)
 | 
			
		||||
                    .accessDeniedHandler(accessDeniedHandler);
 | 
			
		||||
                // 登录、登录暂时不使用 Spring Security 的拓展点,主要考虑一方面拓展多用户、多种登录方式相对复杂,一方面用户的学习成本较高
 | 
			
		||||
                .accessDeniedHandler(accessDeniedHandler);
 | 
			
		||||
        // 登录、登录暂时不使用 Spring Security 的拓展点,主要考虑一方面拓展多用户、多种登录方式相对复杂,一方面用户的学习成本较高
 | 
			
		||||
 | 
			
		||||
        // 获得 @PermitAll 带来的 URL 列表,免登录
 | 
			
		||||
        Multimap<HttpMethod, String> permitAllUrls = getPermitAllUrlsFromAnnotations();
 | 
			
		||||
@@ -118,23 +118,25 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap
 | 
			
		||||
        httpSecurity
 | 
			
		||||
                // ①:全局共享规则
 | 
			
		||||
                .authorizeRequests()
 | 
			
		||||
                    // 1.1 静态资源,可匿名访问
 | 
			
		||||
                    .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
 | 
			
		||||
                    // 1.2 设置 @PermitAll 无需认证
 | 
			
		||||
                    .antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
 | 
			
		||||
                    .antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
 | 
			
		||||
                    .antMatchers(HttpMethod.PUT, permitAllUrls.get(HttpMethod.PUT).toArray(new String[0])).permitAll()
 | 
			
		||||
                    .antMatchers(HttpMethod.DELETE, permitAllUrls.get(HttpMethod.DELETE).toArray(new String[0])).permitAll()
 | 
			
		||||
                    // 1.3 基于 yudao.security.permit-all-urls 无需认证
 | 
			
		||||
                    .antMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll()
 | 
			
		||||
                    // 1.4 设置 App API 无需认证
 | 
			
		||||
                    .antMatchers(buildAppApi("/**")).permitAll()
 | 
			
		||||
                // 1.1 静态资源,可匿名访问
 | 
			
		||||
                .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
 | 
			
		||||
                // 1.2 设置 @PermitAll 无需认证
 | 
			
		||||
                .antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
 | 
			
		||||
                .antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
 | 
			
		||||
                .antMatchers(HttpMethod.PUT, permitAllUrls.get(HttpMethod.PUT).toArray(new String[0])).permitAll()
 | 
			
		||||
                .antMatchers(HttpMethod.DELETE, permitAllUrls.get(HttpMethod.DELETE).toArray(new String[0])).permitAll()
 | 
			
		||||
                // 1.3 基于 yudao.security.permit-all-urls 无需认证
 | 
			
		||||
                .antMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll()
 | 
			
		||||
                // 1.4 设置 App API 无需认证
 | 
			
		||||
                .antMatchers(buildAppApi("/**")).permitAll()
 | 
			
		||||
                // 1.5 验证码captcha 允许匿名访问
 | 
			
		||||
                .antMatchers("/captcha/get", "/captcha/check").permitAll()
 | 
			
		||||
                // ②:每个项目的自定义规则
 | 
			
		||||
                .and().authorizeRequests(registry -> // 下面,循环设置自定义规则
 | 
			
		||||
                        authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(registry)))
 | 
			
		||||
                // ③:兜底规则,必须认证
 | 
			
		||||
                .authorizeRequests()
 | 
			
		||||
                    .anyRequest().authenticated()
 | 
			
		||||
                .anyRequest().authenticated()
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        // 添加 Token Filter
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user