From e6aea5da5e4fabf064f3c268d67b533c8753110c Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 28 八月 2024 18:49:22 +0800
Subject: [PATCH] 1

---
 se-auth/src/main/java/com/se/auth/service/SysPasswordService.java |    5 +-
 se-auth/pom.xml                                                   |    1 
 se-gateway/src/main/java/com/se/gateway/config/CorsConfig.java    |   59 +++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/se-auth/pom.xml b/se-auth/pom.xml
index 077b5b6..711eefa 100644
--- a/se-auth/pom.xml
+++ b/se-auth/pom.xml
@@ -56,6 +56,7 @@
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
+            <version>1.18.22</version>
             <optional>true</optional>
         </dependency>
     </dependencies>
diff --git a/se-auth/src/main/java/com/se/auth/service/SysPasswordService.java b/se-auth/src/main/java/com/se/auth/service/SysPasswordService.java
index fbd3d8d..8efc6ab 100644
--- a/se-auth/src/main/java/com/se/auth/service/SysPasswordService.java
+++ b/se-auth/src/main/java/com/se/auth/service/SysPasswordService.java
@@ -16,6 +16,7 @@
  * @author admin
  */
 @Component
+@SuppressWarnings("ALL")
 public class SysPasswordService
 {
     @Autowired
@@ -50,12 +51,12 @@
             retryCount = 0;
         }
 
-        if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
+        /*if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
         {
             String errMsg = String.format("瀵嗙爜杈撳叆閿欒%s娆★紝甯愭埛閿佸畾%s鍒嗛挓", maxRetryCount, lockTime);
             recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL,errMsg);
             throw new ServiceException(errMsg);
-        }
+        }*/
 
         if (!matches(user, password))
         {
diff --git a/se-gateway/src/main/java/com/se/gateway/config/CorsConfig.java b/se-gateway/src/main/java/com/se/gateway/config/CorsConfig.java
new file mode 100644
index 0000000..b6a358f
--- /dev/null
+++ b/se-gateway/src/main/java/com/se/gateway/config/CorsConfig.java
@@ -0,0 +1,59 @@
+package com.se.gateway.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.web.cors.reactive.CorsUtils;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+import reactor.core.publisher.Mono;
+
+/**
+ * 璺ㄥ煙閰嶇疆
+ *
+ * @author se
+ * @date 2024-08-28
+ */
+@Configuration
+public class CorsConfig
+{
+    /**
+     * 杩欓噷涓烘敮鎸佺殑璇锋眰澶达紝濡傛灉鏈夎嚜瀹氫箟鐨刪eader瀛楁璇疯嚜宸辨坊鍔�
+     */
+    // private static final String ALLOWED_HEADERS = "X-Requested-With, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, Admin-Token, App-Token"
+    private static final String ALLOWED_HEADERS = "*";
+    private static final String ALLOWED_METHODS = "GET,POST,PUT,DELETE,OPTIONS,HEAD";
+    private static final String ALLOWED_ORIGIN = "*";
+    private static final String ALLOWED_EXPOSE = "*";
+    private static final String MAX_AGE = "18000L";
+
+    @Bean
+    public WebFilter corsFilter()
+    {
+        return (ServerWebExchange ctx, WebFilterChain chain) -> {
+            ServerHttpRequest request = ctx.getRequest();
+            if (CorsUtils.isCorsRequest(request))
+            {
+                ServerHttpResponse response = ctx.getResponse();
+                HttpHeaders headers = response.getHeaders();
+                headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
+                headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
+                headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
+                headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE);
+                headers.add("Access-Control-Max-Age", MAX_AGE);
+                headers.add("Access-Control-Allow-Credentials", "true");
+                if (request.getMethod() == HttpMethod.OPTIONS)
+                {
+                    response.setStatusCode(HttpStatus.OK);
+                    return Mono.empty();
+                }
+            }
+            return chain.filter(ctx);
+        };
+    }
+}

--
Gitblit v1.9.3