| | |
| | | |
| | | import cn.dev33.satoken.annotation.SaIgnore; |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | 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.constant.SystemConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.domain.model.LoginBody; |
| | | import org.dromara.common.core.domain.model.RegisterBody; |
| | |
| | | if (ObjectUtil.isNull(client) || !StringUtils.contains(client.getGrantType(), grantType)) { |
| | | log.info("客户端id: {} 认证类型:{} 异常!.", clientId, grantType); |
| | | return R.fail(MessageUtils.message("auth.grant.type.error")); |
| | | } else if (!UserConstants.NORMAL.equals(client.getStatus())) { |
| | | } else if (!SystemConstants.NORMAL.equals(client.getStatus())) { |
| | | return R.fail(MessageUtils.message("auth.grant.type.blocked")); |
| | | } |
| | | // 校验租户 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 第三方登录请求 |
| | | * 获取跳转URL |
| | | * |
| | | * @param source 登录来源 |
| | | * @return 结果 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 第三方登录回调业务处理 绑定授权 |
| | | * 前端回调绑定授权(需要token) |
| | | * |
| | | * @param loginBody 请求体 |
| | | * @return 结果 |
| | | */ |
| | | @PostMapping("/social/callback") |
| | | public R<Void> socialCallback(@RequestBody SocialLoginBody loginBody) { |
| | | // 校验token |
| | | StpUtil.checkLogin(); |
| | | // 获取第三方登录信息 |
| | | AuthResponse<AuthUser> response = SocialUtils.loginAuth( |
| | | loginBody.getSource(), loginBody.getSocialCode(), |
| | |
| | | |
| | | |
| | | /** |
| | | * 取消授权 |
| | | * 取消授权(需要token) |
| | | * |
| | | * @param socialId socialId |
| | | */ |
| | | @DeleteMapping(value = "/unlock/{socialId}") |
| | | public R<Void> unlockSocial(@PathVariable Long socialId) { |
| | | // 校验token |
| | | StpUtil.checkLogin(); |
| | | Boolean rows = socialUserService.deleteWithValidById(socialId); |
| | | return rows ? R.ok() : R.fail("取消授权失败"); |
| | | } |
| | |
| | | } |
| | | // 根据域名进行筛选 |
| | | List<TenantListVo> list = StreamUtils.filter(voList, vo -> |
| | | StringUtils.equals(vo.getDomain(), host)); |
| | | StringUtils.equalsIgnoreCase(vo.getDomain(), host)); |
| | | result.setVoList(CollUtil.isNotEmpty(list) ? list : voList); |
| | | return R.ok(result); |
| | | } |