Browse Source

测试cookie反写

guq 7 years ago
parent
commit
9a8cb02205

+ 13 - 0
base-servers/auth/auth-server/src/main/java/com/usoftchina/saas/auth/controller/AuthController.java

@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -252,6 +253,18 @@ public class AuthController {
             authorizeLogService.save(AuthorizeLog.from(request)
                     .setAccountId(accountDTO.getId())
                     .setAppId(appId).build());
+            //将cookies
+            Cookie[] cookies = request.getCookies();
+            Cookie ssoCookies = null;
+            for (Cookie cookie : cookies) {
+                if (cookieConfig.getName().equals(cookie.getName())) {
+                    ssoCookies = cookie;
+                    break;
+                }
+            }
+            if (null != ssoCookies) {
+                response.addCookie(ssoCookies);
+            }
             // 将登录信息推送到客户端
             if (!StringUtils.isEmpty(clientId)) {
                 Long companyId = null;