فهرست منبع

fix 授权重定向跳转

zoujiajian 2 سال پیش
والد
کامیت
d2625b13d2

+ 4 - 1
netflix-service/src/main/java/com/cyksj/service/authorization/AuthorizationService.java

@@ -2,6 +2,8 @@ package com.cyksj.service.authorization;
 
 import com.cyksj.model.dto.JsSdkTicket;
 
+import java.net.MalformedURLException;
+
 /**
  * @author chan
  * @className AuthorizationService
@@ -12,11 +14,12 @@ public interface AuthorizationService {
 
     /**
      * 微信授权转发地址
+     *
      * @param state
      * @param authType
      * @return
      */
-    String createUrl(String state, String authType);
+    String createUrl(String url, String state, String authType) throws MalformedURLException;
 
     JsSdkTicket getJsTicket(String appId, String url) throws Exception;
 

+ 22 - 4
netflix-service/src/main/java/com/cyksj/service/authorization/impl/AuthorizationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.authorization.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.cyksj.common.util.Codec;
 import com.cyksj.config.WeChatConfig;
 import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
@@ -11,6 +12,8 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 
@@ -33,11 +36,11 @@ public class AuthorizationServiceImpl implements AuthorizationService {
 
 
     @Override
-    public String createUrl(String state, String authType) {
-        return weChatService.createUrl(state,weChatConfig.getDomain() + WeChatAuthRedirectUrl.get(authType).getUrl()
-                ,weChatConfig.getAppid(),WeChatAuthRedirectUrl.get(authType).getScope());
+    public String createUrl(String url, String state, String authType) throws MalformedURLException {
+        String domain = gerUrlDomain(url);
+        return weChatService.createUrl(state, (domain != null ? domain : weChatConfig.getDomain()) + WeChatAuthRedirectUrl.get(authType).getUrl()
+                , weChatConfig.getAppid(), WeChatAuthRedirectUrl.get(authType).getScope());
     }
-
     @Override
     public JsSdkTicket getJsTicket(String appId, String url) throws Exception {
 
@@ -66,4 +69,19 @@ public class AuthorizationServiceImpl implements AuthorizationService {
         return weChatService.createWxAuthLoginUrl(state, appId, URLEncoder.encode(redirectUrl, StandardCharsets.UTF_8));
     }
 
+    public static String gerUrlDomain(String url) {
+        try {
+            if (StrUtil.isNotBlank(url) && !url.contains("nf.video")) {
+                if (!url.contains("http")) {
+                    url = "https://" + url;
+                }
+                URL questUrl = new URL(url);
+                String domain = questUrl.getAuthority();
+                return "https://" + domain + "/";
+            }
+        } catch (MalformedURLException e) {
+        }
+        return null;
+    }
+
 }

+ 2 - 2
netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java

@@ -113,7 +113,7 @@ public class AuthorizationController {
                 .setCst(cst);
         String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
 
-        response.sendRedirect(authorizationService.createUrl(state, authType));
+        response.sendRedirect(authorizationService.createUrl(url, state, authType));
 
     }
 
@@ -510,7 +510,7 @@ public class AuthorizationController {
         }
 
         log.info("微信授权转跳.url: {}", url);
-        response.sendRedirect(url.contains("?") ? url + "&t=" + StpUserUtil.getTokenValue() : url + "?t=" + StpUserUtil.getTokenValue());
+        response.sendRedirect(url);
     }
 
     @PostMapping("/google/login")

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
netflix-web/src/main/resources/application-prd.yml


+ 4 - 4
netflix-web/src/main/resources/application-pre.yml

@@ -88,10 +88,10 @@ spring:
 sa-token:
   # token名称 (同时也是cookie名称)
   token-name: satoken
-  # token有效期,单位s 默认30天, -1代表永不过期
-  timeout: 2592000
-  # token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
-  activity-timeout: -1
+  # token有效期,单位s 默认7天, -1代表永不过期
+  timeout: 604800
+  # token临时有效期 3天 (指定时间内无操作就视为token过期) 单位: 秒
+  activity-timeout: 259200
   # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
   is-concurrent: true
   # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است