This commit is contained in:
D 2024-04-16 18:32:38 +08:00
parent 2ad71746f3
commit 6cd2624c82
11 changed files with 547 additions and 596 deletions

View File

@ -93,7 +93,7 @@ com.ruoyi
├── ruoyi-online // 在线开发模块(可移除) ├── ruoyi-online // 在线开发模块(可移除)
├── ruoyi-oauth // 第三方认证框架(测试中) ├── ruoyi-oauth // 第三方认证框架(测试中)
│ └── common // 第三方认证基础模块(开发中) │ └── common // 第三方认证基础模块(开发中)
│ └── justauth // 网站第三方认证模块(开发中 │ └── justauth // 网站第三方认证模块(测试中参照若依扩展改进因没有这么多场景的code请大家测试出问题后help解决一下发出来
│ └── wx // 微信小程序认证模块(测试中) │ └── wx // 微信小程序认证模块(测试中)
│ └── phone // 手机认证模块(测试中) │ └── phone // 手机认证模块(测试中)
│ └── email // 邮箱认证模块(开发中) │ └── email // 邮箱认证模块(开发中)

View File

@ -2,6 +2,8 @@ package com.ruoyi.oauth.common.mapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.oauth.common.domain.OauthUser; import com.ruoyi.oauth.common.domain.OauthUser;
/** /**
@ -18,6 +20,7 @@ public interface OauthUserMapper {
* @return 第三方认证 * @return 第三方认证
*/ */
public OauthUser selectOauthUserById(Long id); public OauthUser selectOauthUserById(Long id);
public OauthUser selectOauthUserByUserId(Long userId); public OauthUser selectOauthUserByUserId(Long userId);
/** /**
@ -72,4 +75,38 @@ public interface OauthUserMapper {
* @return 结果 * @return 结果
*/ */
public int deleteOauthUserByIds(Long[] ids); public int deleteOauthUserByIds(Long[] ids);
/**
* 校验source平台是否绑定
*
* @param userId 用户编号
* @param source 绑定平台
* @return 结果
*/
public int checkAuthUser(@Param("userId") Long userId, @Param("source") String source);
/**
* 校验用户名称是否唯一
*
* @param userName 用户名称
* @return 结果
*/
public int checkUserNameUnique(String userName);
/**
* 校验手机号码是否唯一
*
* @param phonenumber 手机号码
* @return 结果
*/
public int checkPhoneUnique(String phonenumber);
/**
* 校验email是否唯一
*
* @param email 用户邮箱
* @return 结果
*/
public int checkEmailUnique(String email);
} }

View File

@ -2,6 +2,7 @@ package com.ruoyi.oauth.common.service;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.oauth.common.domain.OauthUser; import com.ruoyi.oauth.common.domain.OauthUser;
/** /**
@ -10,8 +11,7 @@ import com.ruoyi.oauth.common.domain.OauthUser;
* @author Dftre * @author Dftre
* @date 2024-01-18 * @date 2024-01-18
*/ */
public interface IOauthUserService public interface IOauthUserService {
{
/** /**
* 查询第三方认证 * 查询第三方认证
* *
@ -19,9 +19,12 @@ public interface IOauthUserService
* @return 第三方认证 * @return 第三方认证
*/ */
public OauthUser selectOauthUserById(Long id); public OauthUser selectOauthUserById(Long id);
public OauthUser selectOauthUserByUUID(String uuid); public OauthUser selectOauthUserByUUID(String uuid);
public OauthUser selectOauthUserByUserId(Long userId); public OauthUser selectOauthUserByUserId(Long userId);
public SysUser selectSysUserByUUID(String uuid);
/** /**
* 查询第三方认证列表 * 查询第三方认证列表
@ -62,4 +65,38 @@ public interface IOauthUserService
* @return 结果 * @return 结果
*/ */
public int deleteOauthUserById(Long id); public int deleteOauthUserById(Long id);
/**
* 校验source平台是否绑定
*
* @param userId 用户编号
* @param source 绑定平台
* @return 结果
*/
public boolean checkAuthUser(Long userId, String source);
/**
* 校验用户名称是否唯一
*
* @param userName 用户名称
* @return 结果
*/
public boolean checkUserNameUnique(String userName);
/**
* 校验手机号码是否唯一
*
* @param phonenumber 手机号码
* @return 结果
*/
public boolean checkPhoneUnique(String phonenumber);
/**
* 校验email是否唯一
*
* @param email 用户邮箱
* @return 结果
*/
public boolean checkEmailUnique(String email);
} }

View File

@ -5,9 +5,11 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.oauth.common.domain.OauthUser; import com.ruoyi.oauth.common.domain.OauthUser;
import com.ruoyi.oauth.common.mapper.OauthUserMapper; import com.ruoyi.oauth.common.mapper.OauthUserMapper;
import com.ruoyi.oauth.common.service.IOauthUserService; import com.ruoyi.oauth.common.service.IOauthUserService;
import com.ruoyi.system.mapper.SysUserMapper;
/** /**
* 第三方认证Service业务层处理 * 第三方认证Service业务层处理
@ -16,11 +18,13 @@ import com.ruoyi.oauth.common.service.IOauthUserService;
* @date 2024-01-18 * @date 2024-01-18
*/ */
@Service @Service
public class OauthUserServiceImpl implements IOauthUserService public class OauthUserServiceImpl implements IOauthUserService {
{
@Autowired @Autowired
private OauthUserMapper oauthUserMapper; private OauthUserMapper oauthUserMapper;
@Autowired
private SysUserMapper sysUserMapper;
/** /**
* 查询第三方认证 * 查询第三方认证
* *
@ -28,20 +32,20 @@ public class OauthUserServiceImpl implements IOauthUserService
* @return 第三方认证 * @return 第三方认证
*/ */
@Override @Override
public OauthUser selectOauthUserById(Long id) public OauthUser selectOauthUserById(Long id) {
{
return oauthUserMapper.selectOauthUserById(id); return oauthUserMapper.selectOauthUserById(id);
} }
@Override @Override
public OauthUser selectOauthUserByUUID(String uuid) public OauthUser selectOauthUserByUUID(String uuid) {
{
return oauthUserMapper.selectOauthUserByUUID(uuid); return oauthUserMapper.selectOauthUserByUUID(uuid);
} }
@Override @Override
public OauthUser selectOauthUserByUserId(Long userId) public OauthUser selectOauthUserByUserId(Long userId) {
{
return oauthUserMapper.selectOauthUserByUserId(userId); return oauthUserMapper.selectOauthUserByUserId(userId);
} }
/** /**
* 查询第三方认证列表 * 查询第三方认证列表
* *
@ -49,8 +53,7 @@ public class OauthUserServiceImpl implements IOauthUserService
* @return 第三方认证 * @return 第三方认证
*/ */
@Override @Override
public List<OauthUser> selectOauthUserList(OauthUser oauthUser) public List<OauthUser> selectOauthUserList(OauthUser oauthUser) {
{
return oauthUserMapper.selectOauthUserList(oauthUser); return oauthUserMapper.selectOauthUserList(oauthUser);
} }
@ -61,8 +64,7 @@ public class OauthUserServiceImpl implements IOauthUserService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertOauthUser(OauthUser oauthUser) public int insertOauthUser(OauthUser oauthUser) {
{
return oauthUserMapper.insertOauthUser(oauthUser); return oauthUserMapper.insertOauthUser(oauthUser);
} }
@ -73,8 +75,7 @@ public class OauthUserServiceImpl implements IOauthUserService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateOauthUser(OauthUser oauthUser) public int updateOauthUser(OauthUser oauthUser) {
{
return oauthUserMapper.updateOauthUser(oauthUser); return oauthUserMapper.updateOauthUser(oauthUser);
} }
@ -85,8 +86,7 @@ public class OauthUserServiceImpl implements IOauthUserService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteOauthUserByIds(Long[] ids) public int deleteOauthUserByIds(Long[] ids) {
{
return oauthUserMapper.deleteOauthUserByIds(ids); return oauthUserMapper.deleteOauthUserByIds(ids);
} }
@ -97,8 +97,53 @@ public class OauthUserServiceImpl implements IOauthUserService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteOauthUserById(Long id) public int deleteOauthUserById(Long id) {
{
return oauthUserMapper.deleteOauthUserById(id); return oauthUserMapper.deleteOauthUserById(id);
} }
public SysUser selectSysUserByUUID(String uuid) {
OauthUser oauthUser = oauthUserMapper.selectOauthUserByUUID(uuid);
return sysUserMapper.selectUserById(oauthUser.getUserId());
}
/**
* 校验source平台是否绑定
*
* @param userId 用户编号
* @param source 绑定平台
* @return 结果
*/
public boolean checkAuthUser(Long userId, String source) {
return oauthUserMapper.checkAuthUser(userId, source) > 0;
};
/**
* 校验用户名称是否唯一
*
* @param userName 用户名称
* @return 结果
*/
public boolean checkUserNameUnique(String userName) {
return oauthUserMapper.checkUserNameUnique(userName) > 0;
};
/**
* 校验手机号码是否唯一
*
* @param phonenumber 手机号码
* @return 结果
*/
public boolean checkPhoneUnique(String phonenumber) {
return oauthUserMapper.checkPhoneUnique(phonenumber) > 0;
};
/**
* 校验email是否唯一
*
* @param email 用户邮箱
* @return 结果
*/
public boolean checkEmailUnique(String email) {
return oauthUserMapper.checkEmailUnique(email) > 0;
};
} }

View File

@ -5,31 +5,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.oauth.common.mapper.OauthUserMapper"> <mapper namespace="com.ruoyi.oauth.common.mapper.OauthUserMapper">
<resultMap type="OauthUser" id="OauthUserResult"> <resultMap type="OauthUser" id="OauthUserResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="uuid" column="uuid" /> <result property="uuid" column="uuid" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="source" column="source" /> <result property="source" column="source" />
<result property="accessToken" column="access_token" /> <result property="accessToken" column="access_token" />
<result property="expireIn" column="expire_in" /> <result property="expireIn" column="expire_in" />
<result property="refreshToken" column="refresh_token" /> <result property="refreshToken" column="refresh_token" />
<result property="openId" column="open_id" /> <result property="openId" column="open_id" />
<result property="uid" column="uid" /> <result property="uid" column="uid" />
<result property="accessCode" column="access_code" /> <result property="accessCode" column="access_code" />
<result property="unionId" column="union_id" /> <result property="unionId" column="union_id" />
<result property="scope" column="scope" /> <result property="scope" column="scope" />
<result property="tokenType" column="token_type" /> <result property="tokenType" column="token_type" />
<result property="idToken" column="id_token" /> <result property="idToken" column="id_token" />
<result property="macAlgorithm" column="mac_algorithm" /> <result property="macAlgorithm" column="mac_algorithm" />
<result property="macKey" column="mac_key" /> <result property="macKey" column="mac_key" />
<result property="code" column="code" /> <result property="code" column="code" />
<result property="oauthToken" column="oauth_token" /> <result property="oauthToken" column="oauth_token" />
<result property="oauthTokenSecret" column="oauth_token_secret" /> <result property="oauthTokenSecret" column="oauth_token_secret" />
</resultMap> </resultMap>
<sql id="selectOauthUserVo"> <sql id="selectOauthUserVo">
select id, uuid, user_id, source, access_token, expire_in, refresh_token, open_id, uid, access_code, union_id, scope, token_type, id_token, mac_algorithm, mac_key, code, oauth_token, oauth_token_secret from oauth_user select id, uuid, user_id, source, access_token, expire_in, refresh_token, open_id, uid, access_code, union_id, scope, token_type, id_token, mac_algorithm, mac_key, code, oauth_token, oauth_token_secret from oauth_user
</sql> </sql>
<select id="checkUserNameUnique" parameterType="String" resultType="int">
select count(1) from sys_user where user_name = #{userName} and del_flag = '0' limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultType="int">
select count(1) from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
</select>
<select id="checkEmailUnique" parameterType="String" resultType="int">
select count(1) from sys_user where email = #{email} and del_flag = '0' limit 1
</select>
<select id="checkAuthUser" parameterType="OauthUser" resultType="int">
select count(1) from sys_auth_user where user_id=#{userId} and source=#{source} limit 1
</select>
<select id="selectOauthUserList" parameterType="OauthUser" resultMap="OauthUserResult"> <select id="selectOauthUserList" parameterType="OauthUser" resultMap="OauthUserResult">
<include refid="selectOauthUserVo"/> <include refid="selectOauthUserVo"/>
<where> <where>
@ -91,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="code != null">code,</if> <if test="code != null">code,</if>
<if test="oauthToken != null">oauth_token,</if> <if test="oauthToken != null">oauth_token,</if>
<if test="oauthTokenSecret != null">oauth_token_secret,</if> <if test="oauthTokenSecret != null">oauth_token_secret,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
<if test="uuid != null and uuid != ''">#{uuid},</if> <if test="uuid != null and uuid != ''">#{uuid},</if>
@ -112,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="code != null">#{code},</if> <if test="code != null">#{code},</if>
<if test="oauthToken != null">#{oauthToken},</if> <if test="oauthToken != null">#{oauthToken},</if>
<if test="oauthTokenSecret != null">#{oauthTokenSecret},</if> <if test="oauthTokenSecret != null">#{oauthTokenSecret},</if>
</trim> </trim>
</insert> </insert>
<update id="updateOauthUser" parameterType="OauthUser"> <update id="updateOauthUser" parameterType="OauthUser">

View File

@ -1,114 +0,0 @@
package com.ruoyi.oauth.justauth.controller;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.oauth.justauth.service.OAuthService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/19 9:28
* @since 1.8
*/
@Controller
@RequestMapping("/oauth")
public class OAuthController extends BaseController {
@Autowired
private OAuthService oAuthServiceImpl;
@RequestMapping("/render/{source}")
@ResponseBody
public void renderAuth(@PathVariable("source") String source, HttpServletResponse response) throws IOException {
logger.info("进入render" + source);
AuthRequest authRequest = oAuthServiceImpl.getAuthRequest(source);
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
logger.info(authorizeUrl);
response.sendRedirect(authorizeUrl);
}
/**
* oauth平台中配置的授权回调地址以本项目为例在创建github授权应用时的回调地址应为http://127.0.0.1:8443/oauth/callback/github
*/
@RequestMapping("/callback/{source}")
public AjaxResult login(@PathVariable("source") String source, AuthCallback callback,
HttpServletRequest request) {
logger.info("进入callback" + source + " callback params" + JSONObject.toJSONString(callback));
AuthRequest authRequest = oAuthServiceImpl.getAuthRequest(source);
AuthResponse<AuthUser> response = authRequest.login(callback);
logger.info(JSONObject.toJSONString(response));
if (response.ok()) {
oAuthServiceImpl.save(response.getData());
return success("授权成功!");
}
return error(response.getMsg());
}
@RequestMapping("/revoke/{source}/{uuid}")
@ResponseBody
public AjaxResult revokeAuth(@PathVariable("source") String source, @PathVariable("uuid") String uuid)
throws IOException {
AuthRequest authRequest = oAuthServiceImpl.getAuthRequest(source.toLowerCase());
AuthUser user = oAuthServiceImpl.getByUuid(uuid);
if (null == user) {
return error("用户不存在");
}
AuthResponse<AuthToken> response = null;
try {
response = authRequest.revoke(user.getToken());
if (response.ok()) {
oAuthServiceImpl.remove(user.getUuid());
return success("用户 [" + user.getUsername() + "] 的 授权状态 已收回!");
}
return error("用户 [" + user.getUsername() + "] 的 授权状态 收回失败!" + response.getMsg());
} catch (AuthException e) {
return error(e.getErrorMsg());
}
}
@RequestMapping("/refresh/{source}/{uuid}")
@ResponseBody
public AjaxResult refreshAuth(@PathVariable("source") String source, @PathVariable("uuid") String uuid) {
AuthRequest authRequest = oAuthServiceImpl.getAuthRequest(source.toLowerCase());
AuthUser user = oAuthServiceImpl.getByUuid(uuid);
if (null == user) {
return error("用户不存在");
}
AuthResponse<AuthToken> response = null;
try {
response = authRequest.refresh(user.getToken());
if (response.ok()) {
user.setToken(response.getData());
oAuthServiceImpl.save(user);
return success("用户 [" + user.getUsername() + "] 的 access token 已刷新!新的 accessToken: "
+ response.getData().getAccessToken());
}
return error("用户 [" + user.getUsername() + "] 的 access token 刷新失败!" + response.getMsg());
} catch (AuthException e) {
return error(e.getErrorMsg());
}
}
}

View File

@ -0,0 +1,181 @@
package com.ruoyi.oauth.justauth.controller;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.oauth.common.domain.OauthUser;
import com.ruoyi.oauth.common.service.IOauthUserService;
import com.ruoyi.oauth.justauth.utils.AuthUtils;
import com.ruoyi.system.service.ISysUserService;
import jakarta.servlet.http.HttpServletRequest;
import me.zhyd.oauth.cache.AuthDefaultStateCache;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
/**
* 第三方认证授权处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/auth")
public class SysAuthController extends BaseController
{
private AuthStateCache authStateCache;
@Autowired
private ISysUserService userService;
@Autowired
private SysPermissionService permissionService;
@Autowired
private TokenService tokenService;
@Autowired
private IOauthUserService oauthUserService;
private final static Map<String, String> auths = new HashMap<String, String>();
{
auths.put("gitee", "{\"clientId\":\"d83265831bf1b09765c27a9fd9860a9fbb2d939b13460454e85d3d551eebb157\",\"clientSecret\":\"23e3d066c85fc5ee6eaad91067ad006bb5475796f9b9c024eaf5bd26acadd7a3\",\"redirectUri\":\"http://127.0.0.1:80/social-login?source=gitee\"}");
auths.put("github", "{\"clientId\":\"Iv1.1be0cdcd71aca63b\",\"clientSecret\":\"0d59d28b43152bc8906011624db37b0fed88d154\",\"redirectUri\":\"http://127.0.0.1:80/social-login?source=github\"}");
authStateCache = AuthDefaultStateCache.INSTANCE;
}
/**
* 认证授权
*
* @param source
* @throws IOException
*/
@GetMapping("/binding/{source}")
@ResponseBody
public AjaxResult authBinding(@PathVariable("source") String source, HttpServletRequest request) throws IOException
{
LoginUser tokenUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(tokenUser) && oauthUserService.checkAuthUser(tokenUser.getUserId(), source))
{
return error(source + "平台账号已经绑定");
}
String obj = auths.get(source);
if (StringUtils.isEmpty(obj))
{
return error(source + "平台账号暂不支持");
}
JSONObject json = JSONObject.parseObject(obj);
AuthRequest authRequest = AuthUtils.getAuthRequest(source, json.getString("clientId"), json.getString("clientSecret"), json.getString("redirectUri"), authStateCache);
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
return success(authorizeUrl);
}
/**
* 第三方登录回调
* @param source
* @param callback
* @param request
* @return
*/
@SuppressWarnings("unchecked")
@Anonymous
@GetMapping("/social-login/{source}")
public AjaxResult socialLogin(@PathVariable("source") String source, AuthCallback callback, HttpServletRequest request)
{
String obj = auths.get(source);
if (StringUtils.isEmpty(obj))
{
return AjaxResult.error(10002, "第三方平台系统不支持或未提供来源");
}
JSONObject json = JSONObject.parseObject(obj);
AuthRequest authRequest = AuthUtils.getAuthRequest(source, json.getString("clientId"), json.getString("clientSecret"), json.getString("redirectUri"), authStateCache);
AuthResponse<AuthUser> response = authRequest.login(callback);
if (response.ok())
{
LoginUser tokenUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(tokenUser))
{
SysUser user = oauthUserService.selectSysUserByUUID(source + response.getData().getUuid());
if (StringUtils.isNotNull(user))
{
String token = tokenService.createToken(SecurityUtils.getLoginUser());
return success().put(Constants.TOKEN, token);
}
// 若已经登录则直接绑定系统账号
OauthUser authUser = new OauthUser();
// SysUser sysUser = new SysUser();
// sysUser.setAvatar(response.getData().getAvatar());
authUser.setUuid(source + response.getData().getUuid());
authUser.setUserId(SecurityUtils.getUserId());
// sysUser.setUserName(response.getData().getUsername());
// sysUser.setNickName(response.getData().getNickname());
// sysUser.setEmail(response.getData().getEmail());
authUser.setSource(source);
oauthUserService.insertOauthUser(authUser);
// userService.insertUser(sysUser);
String token = tokenService.createToken(SecurityUtils.getLoginUser());
return success().put(Constants.TOKEN, token);
}
SysUser authUser = oauthUserService.selectSysUserByUUID(source + response.getData().getUuid());
if (StringUtils.isNotNull(authUser))
{
SysUser user = userService.selectUserByUserName(authUser.getUserName());
if (StringUtils.isNull(user))
{
throw new ServiceException("登录用户:" + user.getUserName() + " 不存在");
}
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
{
throw new ServiceException("对不起,您的账号:" + user.getUserName() + " 已被删除");
}
else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
{
throw new ServiceException("对不起,您的账号:" + user.getUserName() + " 已停用");
}
LoginUser loginUser = new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
String token = tokenService.createToken(loginUser);
return success().put(Constants.TOKEN, token);
}
else
{
return AjaxResult.error(10002, "对不起,您没有绑定注册用户,请先注册后在个人中心绑定第三方授权信息!");
}
}
return AjaxResult.error(10002, "对不起,授权信息验证不通过,请联系管理员");
}
/**
* 取消授权
*/
@DeleteMapping(value = "/unlock/{authId}")
public AjaxResult unlockAuth(@PathVariable Long authId)
{
return toAjax(oauthUserService.deleteOauthUserById(authId));
}
}

View File

@ -0,0 +1,5 @@
package com.ruoyi.oauth.justauth.domain;
public class AuthInfo {
}

View File

@ -1,412 +0,0 @@
package com.ruoyi.oauth.justauth.service.Impl;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.oauth.justauth.service.OAuthService;
import com.xkcoding.http.config.HttpConfig;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.enums.scope.AuthBaiduScope;
import me.zhyd.oauth.enums.scope.AuthCodingScope;
import me.zhyd.oauth.enums.scope.AuthFacebookScope;
import me.zhyd.oauth.enums.scope.AuthGiteeScope;
import me.zhyd.oauth.enums.scope.AuthGithubScope;
import me.zhyd.oauth.enums.scope.AuthGitlabScope;
import me.zhyd.oauth.enums.scope.AuthGoogleScope;
import me.zhyd.oauth.enums.scope.AuthHuaweiScope;
import me.zhyd.oauth.enums.scope.AuthMicrosoftScope;
import me.zhyd.oauth.enums.scope.AuthWeiboScope;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthAlipayRequest;
import me.zhyd.oauth.request.AuthAliyunRequest;
import me.zhyd.oauth.request.AuthBaiduRequest;
import me.zhyd.oauth.request.AuthCodingRequest;
import me.zhyd.oauth.request.AuthCsdnRequest;
import me.zhyd.oauth.request.AuthDingTalkRequest;
import me.zhyd.oauth.request.AuthDouyinRequest;
import me.zhyd.oauth.request.AuthElemeRequest;
import me.zhyd.oauth.request.AuthFacebookRequest;
import me.zhyd.oauth.request.AuthFeishuRequest;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthGithubRequest;
import me.zhyd.oauth.request.AuthGitlabRequest;
import me.zhyd.oauth.request.AuthGoogleRequest;
import me.zhyd.oauth.request.AuthHuaweiRequest;
import me.zhyd.oauth.request.AuthKujialeRequest;
import me.zhyd.oauth.request.AuthLinkedinRequest;
import me.zhyd.oauth.request.AuthMeituanRequest;
import me.zhyd.oauth.request.AuthMiRequest;
import me.zhyd.oauth.request.AuthMicrosoftRequest;
import me.zhyd.oauth.request.AuthOschinaRequest;
import me.zhyd.oauth.request.AuthPinterestRequest;
import me.zhyd.oauth.request.AuthQqRequest;
import me.zhyd.oauth.request.AuthRenrenRequest;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.request.AuthStackOverflowRequest;
import me.zhyd.oauth.request.AuthTaobaoRequest;
import me.zhyd.oauth.request.AuthTeambitionRequest;
import me.zhyd.oauth.request.AuthToutiaoRequest;
import me.zhyd.oauth.request.AuthTwitterRequest;
import me.zhyd.oauth.request.AuthWeChatEnterpriseQrcodeRequest;
import me.zhyd.oauth.request.AuthWeChatMpRequest;
import me.zhyd.oauth.request.AuthWeChatOpenRequest;
import me.zhyd.oauth.request.AuthWeiboRequest;
import me.zhyd.oauth.request.AuthXmlyRequest;
import me.zhyd.oauth.utils.AuthScopeUtils;
@Service
public class OAuthServiceImpl implements OAuthService {
@Autowired
private RedisCache redisCache;
@Override
public AuthUser save(AuthUser user) {
redisCache.setCacheObject(user.getUuid(), user);
return user;
}
@Override
public AuthUser getByUuid(String uuid) {
Object user = redisCache.getCacheObject(uuid);
if (null == user) {
return null;
}
return JSONObject.parseObject(JSONObject.toJSONString(user), AuthUser.class);
}
@Override
public void remove(String uuid) {
redisCache.deleteObject(uuid);
}
/**
* 根据具体的授权来源获取授权请求工具类
*
* @param source
* @return
*/
public AuthRequest getAuthRequest(String source) {
AuthRequest authRequest = null;
switch (source.toLowerCase()) {
case "dingtalk":
authRequest = new AuthDingTalkRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/dingtalk")
.build());
break;
case "baidu":
authRequest = new AuthBaiduRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/baidu")
.scopes(Arrays.asList(
AuthBaiduScope.BASIC.getScope(),
AuthBaiduScope.SUPER_MSG.getScope(),
AuthBaiduScope.NETDISK.getScope()))
.build());
break;
case "github":
authRequest = new AuthGithubRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/github")
.scopes(AuthScopeUtils.getScopes(AuthGithubScope.values()))
// 针对国外平台配置代理
.httpConfig(HttpConfig.builder()
.timeout(15000)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build())
.build());
break;
case "gitee":
authRequest = new AuthGiteeRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://127.0.0.1:8443/oauth/callback/gitee")
.scopes(AuthScopeUtils.getScopes(AuthGiteeScope.values()))
.build());
break;
case "weibo":
authRequest = new AuthWeiboRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/weibo")
.scopes(Arrays.asList(
AuthWeiboScope.EMAIL.getScope(),
AuthWeiboScope.FRIENDSHIPS_GROUPS_READ.getScope(),
AuthWeiboScope.STATUSES_TO_ME_READ.getScope()))
.build());
break;
case "coding":
authRequest = new AuthCodingRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/coding")
.domainPrefix("")
.scopes(Arrays.asList(
AuthCodingScope.USER.getScope(),
AuthCodingScope.USER_EMAIL.getScope(),
AuthCodingScope.USER_PHONE.getScope()))
.build());
break;
case "oschina":
authRequest = new AuthOschinaRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/oschina")
.build());
break;
case "alipay":
// 支付宝在创建回调地址时不允许使用localhost或者127.0.0.1所以这儿的回调地址使用的局域网内的ip
authRequest = new AuthAlipayRequest(AuthConfig.builder()
.clientId("APPID")
.clientSecret("应用私钥")
.alipayPublicKey("支付宝公钥")
.redirectUri("https://www.zhyd.me/oauth/callback/alipay")
.build());
break;
case "qq":
authRequest = new AuthQqRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/qq")
.build());
break;
case "wechat_open":
authRequest = new AuthWeChatOpenRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://www.zhyd.me/oauth/callback/wechat")
.build());
break;
case "csdn":
authRequest = new AuthCsdnRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/csdn")
.build());
break;
case "taobao":
authRequest = new AuthTaobaoRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/taobao")
.build());
break;
case "google":
authRequest = new AuthGoogleRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/google")
.scopes(AuthScopeUtils.getScopes(AuthGoogleScope.USER_EMAIL, AuthGoogleScope.USER_PROFILE,
AuthGoogleScope.USER_OPENID))
// 针对国外平台配置代理
.httpConfig(HttpConfig.builder()
.timeout(15000)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build())
.build());
break;
case "facebook":
authRequest = new AuthFacebookRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("https://justauth.cn/oauth/callback/facebook")
.scopes(AuthScopeUtils.getScopes(AuthFacebookScope.values()))
// 针对国外平台配置代理
.httpConfig(HttpConfig.builder()
.timeout(15000)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build())
.build());
break;
case "douyin":
authRequest = new AuthDouyinRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/douyin")
.build());
break;
case "linkedin":
authRequest = new AuthLinkedinRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/linkedin")
.scopes(null)
.build());
break;
case "microsoft":
authRequest = new AuthMicrosoftRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/microsoft")
.scopes(Arrays.asList(
AuthMicrosoftScope.USER_READ.getScope(),
AuthMicrosoftScope.USER_READWRITE.getScope(),
AuthMicrosoftScope.USER_READBASIC_ALL.getScope(),
AuthMicrosoftScope.USER_READ_ALL.getScope(),
AuthMicrosoftScope.USER_READWRITE_ALL.getScope(),
AuthMicrosoftScope.USER_INVITE_ALL.getScope(),
AuthMicrosoftScope.USER_EXPORT_ALL.getScope(),
AuthMicrosoftScope.USER_MANAGEIDENTITIES_ALL.getScope(),
AuthMicrosoftScope.FILES_READ.getScope()))
.build());
break;
case "mi":
authRequest = new AuthMiRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/mi")
.build());
break;
case "toutiao":
authRequest = new AuthToutiaoRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/toutiao")
.build());
break;
case "teambition":
authRequest = new AuthTeambitionRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://127.0.0.1:8443/oauth/callback/teambition")
.build());
break;
case "pinterest":
authRequest = new AuthPinterestRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("https://eadmin.innodev.com.cn/oauth/callback/pinterest")
// 针对国外平台配置代理
.httpConfig(HttpConfig.builder()
.timeout(15000)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build())
.build());
break;
case "renren":
authRequest = new AuthRenrenRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://127.0.0.1:8443/oauth/callback/teambition")
.build());
break;
case "stack_overflow":
authRequest = new AuthStackOverflowRequest(AuthConfig.builder()
.clientId("")
.clientSecret("((")
.redirectUri("http://localhost:8443/oauth/callback/stack_overflow")
.stackOverflowKey("")
.build());
break;
case "huawei":
authRequest = new AuthHuaweiRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://127.0.0.1:8443/oauth/callback/huawei")
.scopes(Arrays.asList(
AuthHuaweiScope.BASE_PROFILE.getScope(),
AuthHuaweiScope.MOBILE_NUMBER.getScope(),
AuthHuaweiScope.ACCOUNTLIST.getScope(),
AuthHuaweiScope.SCOPE_DRIVE_FILE.getScope(),
AuthHuaweiScope.SCOPE_DRIVE_APPDATA.getScope()))
.build());
break;
case "wechat_enterprise":
authRequest = new AuthWeChatEnterpriseQrcodeRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://justauth.cn/oauth/callback/wechat_enterprise")
.agentId("1000003")
.build());
break;
case "kujiale":
authRequest = new AuthKujialeRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/kujiale")
.build());
break;
case "gitlab":
authRequest = new AuthGitlabRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/gitlab")
.scopes(AuthScopeUtils.getScopes(AuthGitlabScope.values()))
.build());
break;
case "meituan":
authRequest = new AuthMeituanRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/meituan")
.build());
break;
case "eleme":
authRequest = new AuthElemeRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://dblog-web.zhyd.me/oauth/callback/eleme")
.build());
break;
case "twitter":
authRequest = new AuthTwitterRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("https://threelogin.31huiyi.com/oauth/callback/twitter")
// 针对国外平台配置代理
.httpConfig(HttpConfig.builder()
.timeout(15000)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build())
.build());
break;
case "wechat_mp":
authRequest = new AuthWeChatMpRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("")
.build());
break;
case "aliyun":
authRequest = new AuthAliyunRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/aliyun")
.build());
break;
case "xmly":
authRequest = new AuthXmlyRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/xmly")
.build());
break;
case "feishu":
authRequest = new AuthFeishuRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://localhost:8443/oauth/callback/feishu")
.build());
break;
default:
break;
}
if (null == authRequest) {
throw new AuthException("未获取到有效的Auth配置");
}
return authRequest;
}
}

View File

@ -1,21 +0,0 @@
package com.ruoyi.oauth.justauth.service;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthRequest;
public interface OAuthService {
/**
* 根据具体的授权来源获取授权请求工具类
*
* @param source
* @return
*/
public AuthRequest getAuthRequest(String source);
AuthUser save(AuthUser user);
AuthUser getByUuid(String uuid);
void remove(String uuid);
}

View File

@ -0,0 +1,177 @@
package com.ruoyi.oauth.justauth.utils;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.request.AuthAlipayRequest;
import me.zhyd.oauth.request.AuthAliyunRequest;
import me.zhyd.oauth.request.AuthBaiduRequest;
import me.zhyd.oauth.request.AuthCodingRequest;
import me.zhyd.oauth.request.AuthCsdnRequest;
import me.zhyd.oauth.request.AuthDingTalkRequest;
import me.zhyd.oauth.request.AuthDouyinRequest;
import me.zhyd.oauth.request.AuthElemeRequest;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthGithubRequest;
import me.zhyd.oauth.request.AuthGitlabRequest;
import me.zhyd.oauth.request.AuthHuaweiRequest;
import me.zhyd.oauth.request.AuthKujialeRequest;
import me.zhyd.oauth.request.AuthLinkedinRequest;
import me.zhyd.oauth.request.AuthMeituanRequest;
import me.zhyd.oauth.request.AuthMiRequest;
import me.zhyd.oauth.request.AuthMicrosoftRequest;
import me.zhyd.oauth.request.AuthOschinaRequest;
import me.zhyd.oauth.request.AuthPinterestRequest;
import me.zhyd.oauth.request.AuthQqRequest;
import me.zhyd.oauth.request.AuthRenrenRequest;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.request.AuthStackOverflowRequest;
import me.zhyd.oauth.request.AuthTaobaoRequest;
import me.zhyd.oauth.request.AuthTeambitionRequest;
import me.zhyd.oauth.request.AuthToutiaoRequest;
import me.zhyd.oauth.request.AuthWeChatMpRequest;
import me.zhyd.oauth.request.AuthWeChatOpenRequest;
import me.zhyd.oauth.request.AuthWeiboRequest;
/**
* 认证授权工具类
*
* @author ruoyi
*/
public class AuthUtils
{
@SuppressWarnings("deprecation")
public static AuthRequest getAuthRequest(String source, String clientId, String clientSecret, String redirectUri,
AuthStateCache authStateCache)
{
AuthRequest authRequest = null;
switch (source.toLowerCase())
{
case "dingtalk":
authRequest = new AuthDingTalkRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "baidu":
authRequest = new AuthBaiduRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "github":
authRequest = new AuthGithubRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "gitee":
authRequest = new AuthGiteeRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "weibo":
authRequest = new AuthWeiboRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "coding":
authRequest = new AuthCodingRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "oschina":
authRequest = new AuthOschinaRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "alipay":
// 支付宝在创建回调地址时不允许使用localhost或者127.0.0.1所以这儿的回调地址使用的局域网内的ip
authRequest = new AuthAlipayRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.alipayPublicKey("").redirectUri(redirectUri).build(), authStateCache);
break;
case "qq":
authRequest = new AuthQqRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "wechat_open":
authRequest = new AuthWeChatOpenRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build(), authStateCache);
break;
case "csdn":
authRequest = new AuthCsdnRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "taobao":
authRequest = new AuthTaobaoRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "douyin":
authRequest = new AuthDouyinRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "linkedin":
authRequest = new AuthLinkedinRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "microsoft":
authRequest = new AuthMicrosoftRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build(), authStateCache);
break;
case "mi":
authRequest = new AuthMiRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "toutiao":
authRequest = new AuthToutiaoRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "teambition":
authRequest = new AuthTeambitionRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build(), authStateCache);
break;
case "pinterest":
authRequest = new AuthPinterestRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build(), authStateCache);
break;
case "renren":
authRequest = new AuthRenrenRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "stack_overflow":
authRequest = new AuthStackOverflowRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).stackOverflowKey("").build(),
authStateCache);
break;
case "huawei":
authRequest = new AuthHuaweiRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
// case "wechat_enterprise":
// authRequest = new AuthWeChatEnterpriseRequest(AuthConfig.builder().clientId(clientId)
// .clientSecret(clientSecret).redirectUri(redirectUri).agentId("").build(), authStateCache);
// break;
case "kujiale":
authRequest = new AuthKujialeRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "gitlab":
authRequest = new AuthGitlabRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "meituan":
authRequest = new AuthMeituanRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "eleme":
authRequest = new AuthElemeRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
break;
case "wechat_mp":
authRequest = new AuthWeChatMpRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
case "aliyun":
authRequest = new AuthAliyunRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build(), authStateCache);
break;
default:
break;
}
if (null == authRequest)
{
throw new AuthException("未获取到有效的Auth配置");
}
return authRequest;
}
}