mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-16 20:15:06 +08:00
拓展授权登录抽取成单独的starter,拓展配置和默认配置齐平
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.userserver.modules.system.controller.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.*;
|
||||
@ -36,7 +36,7 @@ public class SysAuthController {
|
||||
@Resource
|
||||
private SysSmsCodeService smsCodeService;
|
||||
@Resource
|
||||
private SysSocialService socialService;
|
||||
private SysSocialCoreService socialService;
|
||||
|
||||
|
||||
@PostMapping("/login")
|
||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEn
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||
@ -64,8 +64,8 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
@Resource
|
||||
private SysUserSessionCoreService userSessionCoreService;
|
||||
@Resource
|
||||
private SysSocialService socialService;
|
||||
private static final UserTypeEnum userTypeEnum = UserTypeEnum.MEMBER;
|
||||
private SysSocialCoreService socialService;
|
||||
private static final UserTypeEnum USER_TYPE_ENUM = UserTypeEnum.MEMBER;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException {
|
||||
@ -114,7 +114,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
|
||||
// 如果未绑定 SysSocialUserDO 用户,则无法自动登录,进行报错
|
||||
String unionId = socialService.getAuthUserUnionId(authUser);
|
||||
List<SysSocialUserDO> socialUsers = socialService.getAllSocialUserList(reqVO.getType(), unionId, userTypeEnum);
|
||||
List<SysSocialUserDO> socialUsers = socialService.getAllSocialUserList(reqVO.getType(), unionId, USER_TYPE_ENUM);
|
||||
if (CollUtil.isEmpty(socialUsers)) {
|
||||
throw exception(AUTH_THIRD_LOGIN_NOT_BIND);
|
||||
}
|
||||
@ -130,7 +130,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
LoginUser loginUser = SysAuthConvert.INSTANCE.convert(user);
|
||||
|
||||
// 绑定社交用户(更新)
|
||||
socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser, userTypeEnum);
|
||||
socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser, USER_TYPE_ENUM);
|
||||
|
||||
// 缓存登录用户到 Redis 中,返回 sessionId 编号
|
||||
return userSessionCoreService.createUserSession(loginUser, userIp, userAgent);
|
||||
@ -147,7 +147,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
// loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表
|
||||
|
||||
// 绑定社交用户(新增)
|
||||
socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser, userTypeEnum);
|
||||
socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser, USER_TYPE_ENUM);
|
||||
|
||||
// 缓存登录用户到 Redis 中,返回 sessionId 编号
|
||||
return userSessionCoreService.createUserSession(loginUser, userIp, userAgent);
|
||||
@ -160,7 +160,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
org.springframework.util.Assert.notNull(authUser, "授权用户不为空");
|
||||
|
||||
// 绑定社交用户(新增)
|
||||
socialService.bindSocialUser(userId, reqVO.getType(), authUser, userTypeEnum);
|
||||
socialService.bindSocialUser(userId, reqVO.getType(), authUser, USER_TYPE_ENUM);
|
||||
}
|
||||
|
||||
private LoginUser login0(String username, String password) {
|
||||
@ -271,7 +271,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
reqDTO.setLogType(SysLoginLogTypeEnum.LOGOUT_SELF.getType());
|
||||
reqDTO.setTraceId(TracerUtils.getTraceId());
|
||||
reqDTO.setUserId(userId);
|
||||
reqDTO.setUserType(userTypeEnum.getValue());
|
||||
reqDTO.setUserType(USER_TYPE_ENUM.getValue());
|
||||
reqDTO.setUsername(username);
|
||||
reqDTO.setUserAgent(ServletUtils.getUserAgent());
|
||||
reqDTO.setUserIp(ServletUtils.getClientIP());
|
||||
|
@ -145,24 +145,16 @@ yudao:
|
||||
|
||||
justauth:
|
||||
enabled: true
|
||||
type: # TODO @timfruit:GITEE、DINGTALK、WECHAT_ENTERPRISE 这个几个,对于用户端是不需要的哈,可以删除噢
|
||||
GITEE: # Gitee
|
||||
client-id: ee61f0374a4c6c404a8717094caa7a410d76950e45ff60348015830c519ba5c1
|
||||
client-secret: 7c044a5671be3b051414db0cf2cec6ad702dd298d2416ba24ceaf608e6fa26f9
|
||||
ignore-check-redirect-uri: true
|
||||
DINGTALK: # 钉钉
|
||||
client-id: dingvrnreaje3yqvzhxg
|
||||
client-secret: i8E6iZyDvZj51JIb0tYsYfVQYOks9Cq1lgryEjFRqC79P3iJcrxEwT6Qk2QvLrLI
|
||||
ignore-check-redirect-uri: true
|
||||
WECHAT_ENTERPRISE: # 企业微信
|
||||
client-id: wwd411c69a39ad2e54
|
||||
client-secret: 1wTb7hYxnpT2TUbIeHGXGo7T0odav1ic10mLdyyATOw
|
||||
agent-id: 1000004
|
||||
ignore-check-redirect-uri: true
|
||||
WECHAT_MP: # 微信公众平台 - H5 https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
|
||||
type:
|
||||
WECHAT_MP: # 微信公众平台 - 移动端 H5 https://www.yuque.com/docs/share/a795bef6-ee8a-494a-8dc4-2ef41927743b?#%20%E3%80%8A%E5%BE%AE%E4%BF%A1%E5%85%AC%E4%BC%97%E5%8F%B7%E6%B5%8B%E8%AF%95%E3%80%8B
|
||||
client-id: wxa5a05b85ac361f96
|
||||
client-secret: 247073c7cebb67f27f0e769195c2a57e
|
||||
ignore-check-redirect-uri: true
|
||||
WECHAT_MINI_PROGRAM: # 微信小程序 https://www.yuque.com/docs/share/88e3d30a-6830-45fc-8c25-dae485aef3aa?#%20%E3%80%8A%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%8E%88%E6%9D%83%E7%99%BB%E5%BD%95%E3%80%8B
|
||||
client-id: wx44d047d87e6284d8
|
||||
client-secret: 21c3b7a8a51ee1b8f5cf875848ed4466
|
||||
ignore-check-redirect-uri: true
|
||||
ignore-check-state: true
|
||||
cache:
|
||||
type: REDIS
|
||||
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
|
||||
|
@ -165,17 +165,13 @@ justauth:
|
||||
# client-id: wx5b23ba7a5589ecbb # TODO 芋艿:自己的测试,后续可以删除
|
||||
# client-secret: 2a7b3b20c537e52e74afd395eb85f61f
|
||||
ignore-check-redirect-uri: true
|
||||
extend:
|
||||
enum-class: cn.iocoder.yudao.coreservice.modules.system.compent.justauth.AuthExtendSource
|
||||
config:
|
||||
WECHAT_MINI_PROGRAM: # 微信小程序 https://www.yuque.com/docs/share/88e3d30a-6830-45fc-8c25-dae485aef3aa?#%20%E3%80%8A%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%8E%88%E6%9D%83%E7%99%BB%E5%BD%95%E3%80%8B
|
||||
request-class: cn.iocoder.yudao.coreservice.modules.system.compent.justauth.AuthWeChatMiniProgramRequest
|
||||
client-id: wx44d047d87e6284d8
|
||||
client-secret: 21c3b7a8a51ee1b8f5cf875848ed4466
|
||||
# client-id: wx63c280fe3248a3e7 # TODO 芋艿:自己的测试,后续可以删除
|
||||
# client-secret: 6f270509224a7ae1296bbf1c8cb97aed
|
||||
ignore-check-redirect-uri: true
|
||||
ignore-check-state: true
|
||||
WECHAT_MINI_PROGRAM: # 微信小程序 https://www.yuque.com/docs/share/88e3d30a-6830-45fc-8c25-dae485aef3aa?#%20%E3%80%8A%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%8E%88%E6%9D%83%E7%99%BB%E5%BD%95%E3%80%8B
|
||||
client-id: wx44d047d87e6284d8
|
||||
client-secret: 21c3b7a8a51ee1b8f5cf875848ed4466
|
||||
# client-id: wx63c280fe3248a3e7 # TODO 芋艿:自己的测试,后续可以删除
|
||||
# client-secret: 6f270509224a7ae1296bbf1c8cb97aed
|
||||
ignore-check-redirect-uri: true
|
||||
ignore-check-state: true
|
||||
cache:
|
||||
type: REDIS
|
||||
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
|
||||
|
Reference in New Issue
Block a user