@@ -80,21 +62,19 @@ export default {
code: "",
uuid: ""
},
- oauthProviders: [
- {
+ oauthProviders: [{
img: "https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.2/gitee.png",
title: "码云",
- code: "gitee"
- },
- {
+ source: "gitee",
+ type: 10
+ }, {
img: "https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.2/wechat.png",
title: "微信",
- code: "weixin"
- },
- {
+ source: "weixin"
+ }, {
img: "https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.2/qq.png",
title: "QQ",
- code: "qq"
+ source: "qq"
}
],
loginRules: {
@@ -163,11 +143,15 @@ export default {
});
},
doAuth2Login(provider) {
- console.log("开始Oauth登录...%o", provider.code);
+ // console.log("开始Oauth登录...%o", provider.code);
+ // 设置登陆中
this.loading = true;
- oAuthLogin(provider.code).then((res) => {
- console.log(res.url);
- window.location.href = res.url;
+ // 计算 redirectUri
+ const redirectUri = location.origin + '/third-login';
+ // 进行跳转
+ oAuthLogin(provider.type, redirectUri).then((res) => {
+ // console.log(res.url);
+ window.location.href = res.data;
});
}
}
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java
new file mode 100644
index 000000000..2fa6e3ef8
--- /dev/null
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.framework.common.util.http;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.map.TableMap;
+import cn.hutool.core.net.url.UrlBuilder;
+import cn.hutool.core.util.ReferenceUtil;
+import cn.hutool.core.util.ReflectUtil;
+
+import java.nio.charset.Charset;
+
+/**
+ * HTTP 工具类
+ *
+ * @author 芋道源码
+ */
+public class HttpUtils {
+
+ @SuppressWarnings("unchecked")
+ public static String replaceUrlQuery(String url, String key, String value) {
+ UrlBuilder builder = UrlBuilder.of(url, Charset.defaultCharset());
+ // 先移除
+ TableMap
query = (TableMap)
+ ReflectUtil.getFieldValue(builder.getQuery(), "query");
+ query.remove(key);
+ // 后添加
+ builder.addQuery(key, value);
+ return builder.build();
+ }
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/pom.xml b/yudao-framework/yudao-spring-boot-starter-security/pom.xml
index 35dd3cd19..670a09774 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-security/pom.xml
@@ -44,19 +44,6 @@
spring-boot-starter-security
-
-
- top.dcenter
- justAuth-spring-security-starter
- 1.1.25
-
-
- slf4j-api
- org.slf4j
-
-
-
-
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java
index 46e07c20f..ee253916a 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java
@@ -24,9 +24,6 @@ import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
-import top.dcenter.ums.security.core.oauth.config.Auth2AutoConfigurer;
-import top.dcenter.ums.security.core.oauth.properties.Auth2Properties;
-import top.dcenter.ums.security.core.oauth.properties.OneClickLoginProperties;
import javax.annotation.Resource;
@@ -80,15 +77,6 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap
@Resource
private Customizer.ExpressionInterceptUrlRegistry> authorizeRequestsCustomizer;
- @Autowired
- private Auth2AutoConfigurer auth2AutoConfigurer;
- @Autowired
- private Auth2Properties auth2Properties;
- @Autowired
- private OneClickLoginProperties oneClickLoginProperties;
- @Autowired
- private AbstractSignUpUrlAuthenticationSuccessHandler authenticationSuccessHandler;
-
/**
* 由于 Spring Security 创建 AuthenticationManager 对象时,没声明 @Bean 注解,导致无法被注入
* 通过覆写父类的该方法,添加 @Bean 注解,解决该问题
@@ -129,9 +117,6 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
- // ========= start: 使用 justAuth-spring-security-starter 必须步骤 =========
- // 添加 Auth2AutoConfigurer 使 OAuth2(justAuth) login 生效.
- .apply(this.auth2AutoConfigurer).and()
// 开启跨域
.cors().and()
// CSRF 禁用,因为不使用 Session
@@ -174,19 +159,6 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap
// 添加 JWT Filter
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
-// // 放行第三方登录入口地址与第三方登录回调地址
-// // @formatter:off
-// httpSecurity.authorizeRequests()
-// .antMatchers(HttpMethod.GET,
-// auth2Properties.getRedirectUrlPrefix() + "/*",
-// auth2Properties.getAuthLoginUrlPrefix() + "/*")
-// .permitAll();
-// httpSecurity.authorizeRequests()
-// .antMatchers(HttpMethod.POST,
-// oneClickLoginProperties.getLoginProcessingUrl())
-// .permitAll();
-// // @formatter:on
-// // ========= end: 使用 justAuth-spring-security-starter 必须步骤 =========
}
private String api(String url) {
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/Auth2LoginUser.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/Auth2LoginUser.java
deleted file mode 100644
index 7c39c0568..000000000
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/Auth2LoginUser.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package cn.iocoder.yudao.framework.security.core;
-
-import com.alibaba.fastjson.JSONObject;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import me.zhyd.oauth.enums.AuthUserGender;
-import me.zhyd.oauth.model.AuthToken;
-
-/**
- * @author weir
- */
-@Data
-public class Auth2LoginUser extends LoginUser {
- /**
- * 是否为临时注册的临时用户
- */
- private boolean isTempUser;
- /**
- * 用户第三方系统的唯一id。在调用方集成该组件时,可以用uuid + source唯一确定一个用户
- */
- private String thirdPartyUserId;
- /**
- * 用户昵称
- */
- private String nickname;
- /**
- * 用户头像
- */
- private String avatar;
- /**
- * 用户网址
- */
- private String blog;
- /**
- * 所在公司
- */
- private String company;
- /**
- * 位置
- */
- private String location;
- /**
- * 用户邮箱
- */
- private String email;
- /**
- * 用户备注(各平台中的用户个人介绍)
- */
- private String remark;
- /**
- * 性别
- */
- private AuthUserGender gender;
- /**
- * 用户来源
- */
- private String source;
- /**
- * 用户授权的token信息
- */
- private AuthToken token;
- /**
- * 第三方平台返回的原始用户信息
- */
- private JSONObject rawUserInfo;
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/handler/AbstractSignUpUrlAuthenticationSuccessHandler.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/handler/AbstractSignUpUrlAuthenticationSuccessHandler.java
index b86805ade..01fdf0888 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/handler/AbstractSignUpUrlAuthenticationSuccessHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/handler/AbstractSignUpUrlAuthenticationSuccessHandler.java
@@ -22,24 +22,16 @@
*/
package cn.iocoder.yudao.framework.security.core.handler;
-import cn.iocoder.yudao.framework.security.core.LoginUser;
-import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
import org.springframework.security.web.savedrequest.RequestCache;
-import org.springframework.security.web.savedrequest.SavedRequest;
-import top.dcenter.ums.security.core.oauth.userdetails.TemporaryUser;
-import top.dcenter.ums.security.core.vo.ResponseResult;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import static org.springframework.util.StringUtils.hasText;
-import static top.dcenter.ums.security.core.oauth.util.MvcUtil.*;
-
/**
* @author weir
*/