From afc24f906214828a16a0cd4b94365c33ba886dec Mon Sep 17 00:00:00 2001 From: cjw Date: Mon, 27 May 2024 15:30:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4powerjob=E5=92=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/AuthController.java | 48 ------- .../web/service/impl/SocialAuthStrategy.java | 131 ------------------ ruoyi-common/pom.xml | 1 - ruoyi-common/ruoyi-common-social/pom.xml | 34 ----- .../config/SocialAutoConfiguration.java | 23 --- .../SocialLoginConfigProperties.java | 68 --------- .../config/properties/SocialProperties.java | 29 ---- .../social/maxkey/AuthMaxKeyRequest.java | 80 ----------- .../social/maxkey/AuthMaxKeySource.java | 52 ------- .../social/utils/AuthRedisStateCache.java | 61 -------- .../common/social/utils/SocialUtils.java | 70 ---------- ...ot.autoconfigure.AutoConfiguration.imports | 1 - ruoyi-extend/pom.xml | 1 - ruoyi-extend/ruoyi-powerjob-server/Dockerfile | 17 --- ruoyi-extend/ruoyi-powerjob-server/pom.xml | 68 --------- .../powerjob/PowerJobServerApplication.java | 25 ---- .../main/resources/application-dev.properties | 50 ------- .../resources/application-prod.properties | 50 ------- .../src/main/resources/application.properties | 33 ----- .../src/main/resources/banner.txt | 11 -- .../src/main/resources/logback-plus.xml | 34 ----- 21 files changed, 887 deletions(-) delete mode 100644 ruoyi-admin/src/main/java/org/dromara/web/service/impl/SocialAuthStrategy.java delete mode 100644 ruoyi-common/ruoyi-common-social/pom.xml delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialAutoConfiguration.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeyRequest.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeySource.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java delete mode 100644 ruoyi-common/ruoyi-common-social/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/Dockerfile delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/pom.xml delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/src/main/java/org/dromara/powerjob/PowerJobServerApplication.java delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-dev.properties delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-prod.properties delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application.properties delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/src/main/resources/banner.txt delete mode 100644 ruoyi-extend/ruoyi-powerjob-server/src/main/resources/logback-plus.xml diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index d0d7931..4dfc164 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -6,22 +6,14 @@ import cn.hutool.core.util.ObjectUtil; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import me.zhyd.oauth.model.AuthResponse; -import me.zhyd.oauth.model.AuthUser; -import me.zhyd.oauth.request.AuthRequest; -import me.zhyd.oauth.utils.AuthStateUtils; import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.model.LoginBody; import org.dromara.common.core.domain.model.RegisterBody; -import org.dromara.common.core.domain.model.SocialLoginBody; import org.dromara.common.core.utils.*; import org.dromara.common.encrypt.annotation.ApiEncrypt; import org.dromara.common.json.utils.JsonUtils; import org.dromara.common.satoken.utils.LoginHelper; -import org.dromara.common.social.config.properties.SocialLoginConfigProperties; -import org.dromara.common.social.config.properties.SocialProperties; -import org.dromara.common.social.utils.SocialUtils; import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.websocket.utils.WebSocketUtils; import org.dromara.system.domain.SysClient; @@ -57,7 +49,6 @@ import java.util.concurrent.TimeUnit; @RequestMapping("/auth") public class AuthController { - private final SocialProperties socialProperties; private final SysLoginService loginService; private final SysRegisterService registerService; private final ISysConfigService configService; @@ -101,45 +92,6 @@ public class AuthController { return R.ok(loginVo); } - /** - * 第三方登录请求 - * - * @param source 登录来源 - * @return 结果 - */ - @GetMapping("/binding/{source}") - public R authBinding(@PathVariable("source") String source) { - SocialLoginConfigProperties obj = socialProperties.getType().get(source); - if (ObjectUtil.isNull(obj)) { - return R.fail(source + "平台账号暂不支持"); - } - AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties); - String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); - return R.ok("操作成功", authorizeUrl); - } - - /** - * 第三方登录回调业务处理 绑定授权 - * - * @param loginBody 请求体 - * @return 结果 - */ - @PostMapping("/social/callback") - public R socialCallback(@RequestBody SocialLoginBody loginBody) { - // 获取第三方登录信息 - AuthResponse response = SocialUtils.loginAuth( - loginBody.getSource(), loginBody.getSocialCode(), - loginBody.getSocialState(), socialProperties); - AuthUser authUserData = response.getData(); - // 判断授权响应是否成功 - if (!response.ok()) { - return R.fail(response.getMsg()); - } - loginService.socialRegister(authUserData); - return R.ok(); - } - - /** * 取消授权 * diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/impl/SocialAuthStrategy.java b/ruoyi-admin/src/main/java/org/dromara/web/service/impl/SocialAuthStrategy.java deleted file mode 100644 index a12386e..0000000 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/impl/SocialAuthStrategy.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.dromara.web.service.impl; - -import cn.dev33.satoken.stp.SaLoginModel; -import cn.dev33.satoken.stp.StpUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.http.HttpUtil; -import cn.hutool.http.Method; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import me.zhyd.oauth.model.AuthResponse; -import me.zhyd.oauth.model.AuthUser; -import org.dromara.common.core.domain.model.LoginUser; -import org.dromara.common.core.domain.model.SocialLoginBody; -import org.dromara.common.core.enums.UserStatus; -import org.dromara.common.core.exception.ServiceException; -import org.dromara.common.core.exception.user.UserException; -import org.dromara.common.core.utils.ValidatorUtils; -import org.dromara.common.json.utils.JsonUtils; -import org.dromara.common.satoken.utils.LoginHelper; -import org.dromara.common.social.config.properties.SocialProperties; -import org.dromara.common.social.utils.SocialUtils; -import org.dromara.common.tenant.helper.TenantHelper; -import org.dromara.system.domain.SysClient; -import org.dromara.system.domain.SysUser; -import org.dromara.system.domain.vo.SysSocialVo; -import org.dromara.system.domain.vo.SysUserVo; -import org.dromara.system.mapper.SysUserMapper; -import org.dromara.system.service.ISysSocialService; -import org.dromara.web.domain.vo.LoginVo; -import org.dromara.web.service.IAuthStrategy; -import org.dromara.web.service.SysLoginService; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Optional; - -/** - * 第三方授权策略 - * - * @author thiszhc is 三三 - */ -@Slf4j -@Service("social" + IAuthStrategy.BASE_NAME) -@RequiredArgsConstructor -public class SocialAuthStrategy implements IAuthStrategy { - - private final SocialProperties socialProperties; - private final ISysSocialService sysSocialService; - private final SysUserMapper userMapper; - private final SysLoginService loginService; - - /** - * 登录-第三方授权登录 - * - * @param body 登录信息 - * @param client 客户端信息 - */ - @Override - public LoginVo login(String body, SysClient client) { - SocialLoginBody loginBody = JsonUtils.parseObject(body, SocialLoginBody.class); - ValidatorUtils.validate(loginBody); - AuthResponse response = SocialUtils.loginAuth( - loginBody.getSource(), loginBody.getSocialCode(), - loginBody.getSocialState(), socialProperties); - if (!response.ok()) { - throw new ServiceException(response.getMsg()); - } - AuthUser authUserData = response.getData(); - if ("GITEE".equals(authUserData.getSource())) { - // 如用户使用 gitee 登录顺手 star 给作者一点支持 拒绝白嫖 - HttpUtil.createRequest(Method.PUT, "https://gitee.com/api/v5/user/starred/dromara/RuoYi-Vue-Plus") - .formStr(MapUtil.of("access_token", authUserData.getToken().getAccessToken())) - .executeAsync(); - HttpUtil.createRequest(Method.PUT, "https://gitee.com/api/v5/user/starred/dromara/RuoYi-Cloud-Plus") - .formStr(MapUtil.of("access_token", authUserData.getToken().getAccessToken())) - .executeAsync(); - } - - List list = sysSocialService.selectByAuthId(authUserData.getSource() + authUserData.getUuid()); - if (CollUtil.isEmpty(list)) { - throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!"); - } - Optional opt = list.stream().filter(x -> x.getTenantId().equals(loginBody.getTenantId())).findAny(); - if (opt.isEmpty()) { - throw new ServiceException("对不起,你没有权限登录当前租户!"); - } - SysSocialVo social = opt.get(); - // 查找用户 - SysUserVo user = loadUser(social.getTenantId(), social.getUserId()); - - // 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了 - LoginUser loginUser = loginService.buildLoginUser(user); - loginUser.setClientKey(client.getClientKey()); - loginUser.setDeviceType(client.getDeviceType()); - SaLoginModel model = new SaLoginModel(); - model.setDevice(client.getDeviceType()); - // 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置 - // 例如: 后台用户30分钟过期 app用户1天过期 - model.setTimeout(client.getTimeout()); - model.setActiveTimeout(client.getActiveTimeout()); - model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId()); - // 生成token - LoginHelper.login(loginUser, model); - - LoginVo loginVo = new LoginVo(); - loginVo.setAccessToken(StpUtil.getTokenValue()); - loginVo.setExpireIn(StpUtil.getTokenTimeout()); - loginVo.setClientId(client.getClientId()); - return loginVo; - } - - private SysUserVo loadUser(String tenantId, Long userId) { - return TenantHelper.dynamic(tenantId, () -> { - SysUser user = userMapper.selectOne(new LambdaQueryWrapper() - .select(SysUser::getUserName, SysUser::getStatus) - .eq(SysUser::getUserId, userId)); - if (ObjectUtil.isNull(user)) { - log.info("登录用户:{} 不存在.", ""); - throw new UserException("user.not.exists", ""); - } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { - log.info("登录用户:{} 已被停用.", ""); - throw new UserException("user.blocked", ""); - } - return userMapper.selectUserByUserName(user.getUserName()); - }); - } - -} diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 45493d3..0428aea 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -11,7 +11,6 @@ ruoyi-common-bom - ruoyi-common-social ruoyi-common-core ruoyi-common-doc ruoyi-common-excel diff --git a/ruoyi-common/ruoyi-common-social/pom.xml b/ruoyi-common/ruoyi-common-social/pom.xml deleted file mode 100644 index 9f9a965..0000000 --- a/ruoyi-common/ruoyi-common-social/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - org.dromara - ruoyi-common - ${revision} - - 4.0.0 - - ruoyi-common-social - - - ruoyi-common-social 授权认证 - - - - - me.zhyd.oauth - JustAuth - - - - org.dromara - ruoyi-common-json - - - - org.dromara - ruoyi-common-redis - - - diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialAutoConfiguration.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialAutoConfiguration.java deleted file mode 100644 index 19b39d8..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialAutoConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.dromara.common.social.config; - -import me.zhyd.oauth.cache.AuthStateCache; -import org.dromara.common.social.config.properties.SocialProperties; -import org.dromara.common.social.utils.AuthRedisStateCache; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * Social 配置属性 - * @author thiszhc - */ -@AutoConfiguration -@EnableConfigurationProperties(SocialProperties.class) -public class SocialAutoConfiguration { - - @Bean - public AuthStateCache authStateCache() { - return new AuthRedisStateCache(); - } - -} diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java deleted file mode 100644 index 76be234..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.dromara.common.social.config.properties; - -import lombok.Data; - -/** - * 社交登录配置 - * - * @author thiszhc - */ -@Data -public class SocialLoginConfigProperties { - - /** - * 应用 ID - */ - private String clientId; - - /** - * 应用密钥 - */ - private String clientSecret; - - /** - * 回调地址 - */ - private String redirectUri; - - /** - * 是否获取unionId - */ - private boolean unionId; - - /** - * Coding 企业名称 - */ - private String codingGroupName; - - /** - * 支付宝公钥 - */ - private String alipayPublicKey; - - /** - * 企业微信应用ID - */ - private String agentId; - - /** - * stackoverflow api key - */ - private String stackOverflowKey; - - /** - * 设备ID - */ - private String deviceId; - - /** - * 客户端系统类型 - */ - private String clientOsType; - - /** - * maxkey 服务器地址 - */ - private String serverUrl; - -} diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java deleted file mode 100644 index 1beb7d0..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.dromara.common.social.config.properties; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * Social 配置属性 - * - * @author thiszhc - */ -@Data -@Component -@ConfigurationProperties(prefix = "justauth") -public class SocialProperties { - - /** - * 是否启用 - */ - private Boolean enabled; - - /** - * 授权类型 - */ - private Map type; - -} diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeyRequest.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeyRequest.java deleted file mode 100644 index b95c19e..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeyRequest.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.dromara.common.social.maxkey; - -import cn.hutool.core.lang.Dict; -import me.zhyd.oauth.cache.AuthStateCache; -import me.zhyd.oauth.config.AuthConfig; -import me.zhyd.oauth.exception.AuthException; -import me.zhyd.oauth.model.AuthCallback; -import me.zhyd.oauth.model.AuthToken; -import me.zhyd.oauth.model.AuthUser; -import me.zhyd.oauth.request.AuthDefaultRequest; -import org.dromara.common.core.utils.SpringUtils; -import org.dromara.common.json.utils.JsonUtils; - -/** - * @author 长春叭哥 2023年03月26日 - */ -public class AuthMaxKeyRequest extends AuthDefaultRequest { - - public static final String SERVER_URL = SpringUtils.getProperty("justauth.type.maxkey.server-url"); - - /** - * 设定归属域 - */ - public AuthMaxKeyRequest(AuthConfig config) { - super(config, AuthMaxKeySource.MAXKEY); - } - - public AuthMaxKeyRequest(AuthConfig config, AuthStateCache authStateCache) { - super(config, AuthMaxKeySource.MAXKEY, authStateCache); - } - - @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { - String body = doPostAuthorizationCode(authCallback.getCode()); - Dict object = JsonUtils.parseMap(body); - // oauth/token 验证异常 - if (object.containsKey("error")) { - throw new AuthException(object.getStr("error_description")); - } - // user 验证异常 - if (object.containsKey("message")) { - throw new AuthException(object.getStr("message")); - } - return AuthToken.builder() - .accessToken(object.getStr("access_token")) - .refreshToken(object.getStr("refresh_token")) - .idToken(object.getStr("id_token")) - .tokenType(object.getStr("token_type")) - .scope(object.getStr("scope")) - .build(); - } - - @Override - protected AuthUser getUserInfo(AuthToken authToken) { - String body = doGetUserInfo(authToken); - Dict object = JsonUtils.parseMap(body); - // oauth/token 验证异常 - if (object.containsKey("error")) { - throw new AuthException(object.getStr("error_description")); - } - // user 验证异常 - if (object.containsKey("message")) { - throw new AuthException(object.getStr("message")); - } - return AuthUser.builder() - .uuid(object.getStr("userId")) - .username(object.getStr("username")) - .nickname(object.getStr("displayName")) - .avatar(object.getStr("avatar_url")) - .blog(object.getStr("web_url")) - .company(object.getStr("organization")) - .location(object.getStr("location")) - .email(object.getStr("email")) - .remark(object.getStr("bio")) - .token(authToken) - .source(source.toString()) - .build(); - } - -} diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeySource.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeySource.java deleted file mode 100644 index 1ff57f7..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/maxkey/AuthMaxKeySource.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.dromara.common.social.maxkey; - -import me.zhyd.oauth.config.AuthSource; -import me.zhyd.oauth.request.AuthDefaultRequest; - -/** - * Oauth2 默认接口说明 - * - * @author 长春叭哥 2023年03月26日 - * - */ -public enum AuthMaxKeySource implements AuthSource { - - /** - * 自己搭建的 maxkey 私服 - */ - MAXKEY { - - /** - * 授权的api - */ - @Override - public String authorize() { - return AuthMaxKeyRequest.SERVER_URL + "/sign/authz/oauth/v20/authorize"; - } - - /** - * 获取accessToken的api - */ - @Override - public String accessToken() { - return AuthMaxKeyRequest.SERVER_URL + "/sign/authz/oauth/v20/token"; - } - - /** - * 获取用户信息的api - */ - @Override - public String userInfo() { - return AuthMaxKeyRequest.SERVER_URL + "/sign/api/oauth/v20/me"; - } - - /** - * 平台对应的 AuthRequest 实现类,必须继承自 {@link AuthDefaultRequest} - */ - @Override - public Class getTargetClass() { - return AuthMaxKeyRequest.class; - } - - } -} diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java deleted file mode 100644 index 0b6ec20..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.dromara.common.social.utils; - -import lombok.AllArgsConstructor; -import me.zhyd.oauth.cache.AuthStateCache; -import org.dromara.common.core.constant.GlobalConstants; -import org.dromara.common.redis.utils.RedisUtils; - -import java.time.Duration; - -/** - * 授权状态缓存 - */ -@AllArgsConstructor -public class AuthRedisStateCache implements AuthStateCache { - - /** - * 存入缓存 - * - * @param key 缓存key - * @param value 缓存内容 - */ - @Override - public void cache(String key, String value) { - // 授权超时时间 默认三分钟 - RedisUtils.setCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key, value, Duration.ofMinutes(3)); - } - - /** - * 存入缓存 - * - * @param key 缓存key - * @param value 缓存内容 - * @param timeout 指定缓存过期时间(毫秒) - */ - @Override - public void cache(String key, String value, long timeout) { - RedisUtils.setCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key, value, Duration.ofMillis(timeout)); - } - - /** - * 获取缓存内容 - * - * @param key 缓存key - * @return 缓存内容 - */ - @Override - public String get(String key) { - return RedisUtils.getCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key); - } - - /** - * 是否存在key,如果对应key的value值已过期,也返回false - * - * @param key 缓存key - * @return true:存在key,并且value没过期;false:key不存在或者已过期 - */ - @Override - public boolean containsKey(String key) { - return RedisUtils.hasKey(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key); - } -} diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java deleted file mode 100644 index 51b7e13..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.dromara.common.social.utils; - -import cn.hutool.core.util.ObjectUtil; -import me.zhyd.oauth.config.AuthConfig; -import me.zhyd.oauth.exception.AuthException; -import me.zhyd.oauth.model.AuthCallback; -import me.zhyd.oauth.model.AuthResponse; -import me.zhyd.oauth.model.AuthUser; -import me.zhyd.oauth.request.*; -import org.dromara.common.core.utils.SpringUtils; -import org.dromara.common.social.config.properties.SocialLoginConfigProperties; -import org.dromara.common.social.config.properties.SocialProperties; -import org.dromara.common.social.maxkey.AuthMaxKeyRequest; - -/** - * 认证授权工具类 - * - * @author thiszhc - */ -public class SocialUtils { - - private static final AuthRedisStateCache STATE_CACHE = SpringUtils.getBean(AuthRedisStateCache.class); - - @SuppressWarnings("unchecked") - public static AuthResponse loginAuth(String source, String code, String state, SocialProperties socialProperties) throws AuthException { - AuthRequest authRequest = getAuthRequest(source, socialProperties); - AuthCallback callback = new AuthCallback(); - callback.setCode(code); - callback.setState(state); - return authRequest.login(callback); - } - - public static AuthRequest getAuthRequest(String source, SocialProperties socialProperties) throws AuthException { - SocialLoginConfigProperties obj = socialProperties.getType().get(source); - if (ObjectUtil.isNull(obj)) { - throw new AuthException("不支持的第三方登录类型"); - } - AuthConfig.AuthConfigBuilder builder = AuthConfig.builder() - .clientId(obj.getClientId()) - .clientSecret(obj.getClientSecret()) - .redirectUri(obj.getRedirectUri()); - return switch (source.toLowerCase()) { - case "dingtalk" -> new AuthDingTalkRequest(builder.build(), STATE_CACHE); - case "baidu" -> new AuthBaiduRequest(builder.build(), STATE_CACHE); - case "github" -> new AuthGithubRequest(builder.build(), STATE_CACHE); - case "gitee" -> new AuthGiteeRequest(builder.build(), STATE_CACHE); - case "weibo" -> new AuthWeiboRequest(builder.build(), STATE_CACHE); - case "coding" -> new AuthCodingRequest(builder.build(), STATE_CACHE); - case "oschina" -> new AuthOschinaRequest(builder.build(), STATE_CACHE); - // 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip - case "alipay_wallet" -> new AuthAlipayRequest(builder.build(), socialProperties.getType().get("alipay_wallet").getAlipayPublicKey(), STATE_CACHE); - case "qq" -> new AuthQqRequest(builder.build(), STATE_CACHE); - case "wechat_open" -> new AuthWeChatOpenRequest(builder.build(), STATE_CACHE); - case "taobao" -> new AuthTaobaoRequest(builder.build(), STATE_CACHE); - case "douyin" -> new AuthDouyinRequest(builder.build(), STATE_CACHE); - case "linkedin" -> new AuthLinkedinRequest(builder.build(), STATE_CACHE); - case "microsoft" -> new AuthMicrosoftRequest(builder.build(), STATE_CACHE); - case "renren" -> new AuthRenrenRequest(builder.build(), STATE_CACHE); - case "stack_overflow" -> new AuthStackOverflowRequest(builder.stackOverflowKey("").build(), STATE_CACHE); - case "huawei" -> new AuthHuaweiRequest(builder.build(), STATE_CACHE); - case "wechat_enterprise" -> new AuthWeChatEnterpriseQrcodeRequest(builder.agentId("").build(), STATE_CACHE); - case "gitlab" -> new AuthGitlabRequest(builder.build(), STATE_CACHE); - case "wechat_mp" -> new AuthWeChatMpRequest(builder.build(), STATE_CACHE); - case "aliyun" -> new AuthAliyunRequest(builder.build(), STATE_CACHE); - case "maxkey" -> new AuthMaxKeyRequest(builder.build(), STATE_CACHE); - default -> throw new AuthException("未获取到有效的Auth配置"); - }; - } -} - diff --git a/ruoyi-common/ruoyi-common-social/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-common/ruoyi-common-social/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index fc544a0..0000000 --- a/ruoyi-common/ruoyi-common-social/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -org.dromara.common.social.config.SocialAutoConfiguration diff --git a/ruoyi-extend/pom.xml b/ruoyi-extend/pom.xml index f5348cc..292f9bf 100644 --- a/ruoyi-extend/pom.xml +++ b/ruoyi-extend/pom.xml @@ -13,7 +13,6 @@ ruoyi-monitor-admin - ruoyi-powerjob-server diff --git a/ruoyi-extend/ruoyi-powerjob-server/Dockerfile b/ruoyi-extend/ruoyi-powerjob-server/Dockerfile deleted file mode 100644 index 729bb22..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -#FROM findepi/graalvm:java17-native -FROM openjdk:17.0.2-oraclelinux8 - -MAINTAINER Lion Li - -RUN mkdir -p /ruoyi/powerjob/logs - -WORKDIR /ruoyi/powerjob - -ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS="-Xms512m -Xmx1024m" - -EXPOSE 7700 - -ADD ./target/ruoyi-powerjob-server.jar ./app.jar - -ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -jar app.jar \ - -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC ${JAVA_OPTS} diff --git a/ruoyi-extend/ruoyi-powerjob-server/pom.xml b/ruoyi-extend/ruoyi-powerjob-server/pom.xml deleted file mode 100644 index bdb92a4..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - org.dromara - ruoyi-extend - ${revision} - - 4.0.0 - jar - ruoyi-powerjob-server - - - 2.7.18 - 2.7.11 - - - - - org.springframework.boot - spring-boot-starter-parent - ${spring-boot.version} - pom - import - - - - - - - - - tech.powerjob - powerjob-server-starter - ${powerjob.version} - - - - de.codecentric - spring-boot-admin-starter-client - ${spring-boot-admin.version} - - - - org.projectlombok - lombok - - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - - repackage - - - - - - - - diff --git a/ruoyi-extend/ruoyi-powerjob-server/src/main/java/org/dromara/powerjob/PowerJobServerApplication.java b/ruoyi-extend/ruoyi-powerjob-server/src/main/java/org/dromara/powerjob/PowerJobServerApplication.java deleted file mode 100644 index 3898639..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/src/main/java/org/dromara/powerjob/PowerJobServerApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.dromara.powerjob; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableScheduling; -import tech.powerjob.server.common.utils.PropertyUtils; - -/** - * powerjob 启动程序 - * - * @author yhan219 - */ -@Slf4j -@EnableScheduling -@SpringBootApplication(scanBasePackages = "tech.powerjob.server") -public class PowerJobServerApplication { - - public static void main(String[] args) { - PropertyUtils.init(); - SpringApplication.run(tech.powerjob.server.PowerJobServerApplication.class, args); - log.info("文档地址: https://www.yuque.com/powerjob/guidence/problem"); - } - -} diff --git a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-dev.properties b/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-dev.properties deleted file mode 100644 index ba024d3..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-dev.properties +++ /dev/null @@ -1,50 +0,0 @@ -oms.env=dev - -####### Database properties(Configure according to the the environment) ####### -spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.datasource.core.username=root -spring.datasource.core.password=root -spring.datasource.core.maximum-pool-size=20 -spring.datasource.core.minimum-idle=5 - -# 监控配置 -# 客户端开关 -spring.boot.admin.client.enabled=true -# 设置 Spring Boot Admin Server 地址 -spring.boot.admin.client.url: http://localhost:9090/admin -spring.boot.admin.client.instance.service-host-type=IP -spring.boot.admin.client.username=ruoyi -spring.boot.admin.client.password=123456 - -####### MongoDB properties(Non-core configuration properties) ####### -####### delete mongodb config to disable mongodb ####### -oms.mongodb.enable=false -#spring.data.mongodb.uri=mongodb+srv://zqq:No1Bug2Please3!@cluster0.wie54.gcp.mongodb.net/powerjob_daily?retryWrites=true&w=majority - -####### Email properties(Non-core configuration properties) ####### -####### Delete the following code to disable the mail ####### -#spring.mail.host=smtp.163.com -#spring.mail.username=zqq@163.com -#spring.mail.password=GOFZPNARMVKCGONV -#spring.mail.properties.mail.smtp.auth=true -#spring.mail.properties.mail.smtp.starttls.enable=true -#spring.mail.properties.mail.smtp.starttls.required=true - -####### DingTalk properties(Non-core configuration properties) ####### -####### Delete the following code to disable the DingTalk ####### -#oms.alarm.ding.app-key=dingauqwkvxxnqskknfv -#oms.alarm.ding.app-secret=XWrEPdAZMPgJeFtHuL0LH73LRj-74umF2_0BFcoXMfvnX0pCQvt0rpb1JOJU_HLl -#oms.alarm.ding.agent-id=847044348 - -####### Resource cleaning properties ####### -oms.instanceinfo.retention=1 -oms.container.retention.local=1 -oms.container.retention.remote=-1 - -####### Cache properties ####### -oms.instance.metadata.cache.size=1024 - -####### Threshold in precise fetching server(0~100). 100 means full detection of server, in which ####### -####### split-brain could be avoided while performance overhead would increase. ####### -oms.accurate.select.server.percentage = 50 diff --git a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-prod.properties b/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-prod.properties deleted file mode 100644 index b13c688..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-prod.properties +++ /dev/null @@ -1,50 +0,0 @@ -oms.env=prod - -####### Database properties(Configure according to the the environment) ####### -spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.datasource.core.username=root -spring.datasource.core.password=root -spring.datasource.core.maximum-pool-size=20 -spring.datasource.core.minimum-idle=5 - -# 监控配置 -# 客户端开关 -spring.boot.admin.client.enabled=true -# 设置 Spring Boot Admin Server 地址 -spring.boot.admin.client.url: http://localhost:9090/admin -spring.boot.admin.client.instance.service-host-type=IP -spring.boot.admin.client.username=ruoyi -spring.boot.admin.client.password=123456 - -####### MongoDB properties(Non-core configuration properties) ####### -####### delete mongodb config to disable mongodb ####### -oms.mongodb.enable=false -#spring.data.mongodb.uri=mongodb+srv://zqq:No1Bug2Please3!@cluster0.wie54.gcp.mongodb.net/powerjob_daily?retryWrites=true&w=majority - -####### Email properties(Non-core configuration properties) ####### -####### Delete the following code to disable the mail ####### -#spring.mail.host=smtp.163.com -#spring.mail.username=zqq@163.com -#spring.mail.password=GOFZPNARMVKCGONV -#spring.mail.properties.mail.smtp.auth=true -#spring.mail.properties.mail.smtp.starttls.enable=true -#spring.mail.properties.mail.smtp.starttls.required=true - -####### DingTalk properties(Non-core configuration properties) ####### -####### Delete the following code to disable the DingTalk ####### -#oms.alarm.ding.app-key=dingauqwkvxxnqskknfv -#oms.alarm.ding.app-secret=XWrEPdAZMPgJeFtHuL0LH73LRj-74umF2_0BFcoXMfvnX0pCQvt0rpb1JOJU_HLl -#oms.alarm.ding.agent-id=847044348 - -####### Resource cleaning properties ####### -oms.instanceinfo.retention=7 -oms.container.retention.local=7 -oms.container.retention.remote=-1 - -####### Cache properties ####### -oms.instance.metadata.cache.size=2048 - -####### Threshold in precise fetching server(0~100). 100 means full detection of server, in which ####### -####### split-brain could be avoided while performance overhead would increase. ####### -oms.accurate.select.server.percentage = 50 diff --git a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application.properties b/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application.properties deleted file mode 100644 index 5b6516c..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application.properties +++ /dev/null @@ -1,33 +0,0 @@ -# Http server port -server.port=7700 - -spring.profiles.active=@profiles.active@ -spring.main.banner-mode=log -spring.jpa.open-in-view=false -spring.data.mongodb.repositories.type=none -logging.level.org.mongodb=warn -logging.level.tech.powerjob.server=warn -logging.level.MONITOR_LOGGER_DB_OPERATION=warn -logging.level.MONITOR_LOGGER_WORKER_HEART_BEAT=warn -logging.config: classpath:logback-plus.xml - -# Configuration for uploading files. -spring.servlet.multipart.enabled=true -spring.servlet.multipart.file-size-threshold=0 -spring.servlet.multipart.max-file-size=209715200 -spring.servlet.multipart.max-request-size=209715200 - -###### PowerJob transporter configuration ###### -oms.transporter.active.protocols=AKKA,HTTP -oms.transporter.main.protocol=HTTP -oms.akka.port=10086 -oms.http.port=10010 -# Prefix for all tables. Default empty string. Config if you have needs, i.e. pj_ -oms.table-prefix=pj_ - -# Actuator 监控端点的配置项 -spring.application.name: ruoyi-powerjob-server -management.endpoints.web.exposure.include=* -management.endpoint.health.show-details=ALWAYS -management.endpoint.logfile.external-file=./logs/ruoyi-powerjob-server.log -management.health.mongo.enabled=${oms.mongodb.enable} diff --git a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/banner.txt b/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/banner.txt deleted file mode 100644 index c0fac79..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/banner.txt +++ /dev/null @@ -1,11 +0,0 @@ -Application Version: ${revision} -Spring Boot Version: ${spring-boot.version} - _ _ - (_) | | - _ __ _____ _____ _ __ _ ___ | |__ ______ ___ ___ _ ____ _____ _ __ -| '_ \ / _ \ \ /\ / / _ \ '__| |/ _ \| '_ \______/ __|/ _ \ '__\ \ / / _ \ '__| -| |_) | (_) \ V V / __/ | | | (_) | |_) | \__ \ __/ | \ V / __/ | -| .__/ \___/ \_/\_/ \___|_| | |\___/|_.__/ |___/\___|_| \_/ \___|_| -| | _/ | -|_| |__/ - diff --git a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/logback-plus.xml b/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/logback-plus.xml deleted file mode 100644 index ad3bfa9..0000000 --- a/ruoyi-extend/ruoyi-powerjob-server/src/main/resources/logback-plus.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - logback - - - - - - - ${console.log.pattern} - utf-8 - - - - - ${log.path}.log - - ${log.path}.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - - - - - -