feat: update
This commit is contained in:
@@ -1,54 +1,54 @@
|
||||
package com.schisandra.auth.application.handler.oauth;
|
||||
|
||||
import com.schisandra.auth.common.enums.OauthType;
|
||||
import com.schisandra.auth.common.utils.AuthStateRedisCache;
|
||||
import com.schisandra.auth.infra.entity.OauthConfigInfo;
|
||||
import com.schisandra.auth.infra.rpc.OauthConfigRpc;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthOschinaRequest;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.request.AuthWeChatEnterpriseThirdQrcodeRequest;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Classname OschinaOauthHandler
|
||||
* @BelongsProject: schisandra-cloud-storage
|
||||
* @BelongsPackage: com.schisandra.auth.application.handler.oauth
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-06-26 14:21
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WechatEnterpriseOauthHandler implements SchisandraOauthTypeHandler {
|
||||
@Resource
|
||||
private OauthConfigRpc oauthConfigRpc;
|
||||
|
||||
@Resource
|
||||
private AuthStateRedisCache stateRedisCache;
|
||||
|
||||
@Override
|
||||
public OauthType getHandlerType() {
|
||||
return OauthType.WECHAT_ENTERPRISE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthRequest getAuthRequest(String type) {
|
||||
OauthConfigInfo WECHAT_ENTERPRISE = oauthConfigRpc.getOauthConfigInfo(type);
|
||||
if (ObjectUtils.isEmpty(WECHAT_ENTERPRISE)) {
|
||||
log.error("WECHAT_ENTERPRISE oauth 配置信息获取失败");
|
||||
return null;
|
||||
}
|
||||
return new AuthWeChatEnterpriseThirdQrcodeRequest(AuthConfig.builder()
|
||||
.clientId(WECHAT_ENTERPRISE.getClientId())
|
||||
.clientSecret(WECHAT_ENTERPRISE.getClientSecret())
|
||||
.redirectUri(WECHAT_ENTERPRISE.getRedirectUri())
|
||||
.agentId(WECHAT_ENTERPRISE.getAgentId())
|
||||
.build(), stateRedisCache);
|
||||
}
|
||||
}
|
||||
package com.schisandra.auth.application.handler.oauth;
|
||||
|
||||
import com.schisandra.auth.common.enums.OauthType;
|
||||
import com.schisandra.auth.common.utils.AuthStateRedisCache;
|
||||
import com.schisandra.auth.infra.entity.OauthConfigInfo;
|
||||
import com.schisandra.auth.infra.rpc.OauthConfigRpc;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthOschinaRequest;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.request.AuthWeChatEnterpriseThirdQrcodeRequest;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Classname OschinaOauthHandler
|
||||
* @BelongsProject: schisandra-cloud-storage
|
||||
* @BelongsPackage: com.schisandra.auth.application.handler.oauth
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-06-26 14:21
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WechatEnterpriseOauthHandler implements SchisandraOauthTypeHandler {
|
||||
@Resource
|
||||
private OauthConfigRpc oauthConfigRpc;
|
||||
|
||||
@Resource
|
||||
private AuthStateRedisCache stateRedisCache;
|
||||
|
||||
@Override
|
||||
public OauthType getHandlerType() {
|
||||
return OauthType.WECHAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthRequest getAuthRequest(String type) {
|
||||
OauthConfigInfo WECHAT_ENTERPRISE = oauthConfigRpc.getOauthConfigInfo(type);
|
||||
if (ObjectUtils.isEmpty(WECHAT_ENTERPRISE)) {
|
||||
log.error("WECHAT_ENTERPRISE oauth 配置信息获取失败");
|
||||
return null;
|
||||
}
|
||||
return new AuthWeChatEnterpriseThirdQrcodeRequest(AuthConfig.builder()
|
||||
.clientId(WECHAT_ENTERPRISE.getClientId())
|
||||
.clientSecret(WECHAT_ENTERPRISE.getClientSecret())
|
||||
.redirectUri(WECHAT_ENTERPRISE.getRedirectUri())
|
||||
.agentId(WECHAT_ENTERPRISE.getAgentId())
|
||||
.build(), stateRedisCache);
|
||||
}
|
||||
}
|
||||
|
@@ -1,76 +1,76 @@
|
||||
package com.schisandra.auth.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Classname OauthType
|
||||
* @BelongsProject: schisandra-cloud-storage
|
||||
* @BelongsPackage: com.schisandra.auth.common.enums
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-05-26 13:36
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum OauthType {
|
||||
|
||||
/**
|
||||
* 微信登录
|
||||
*/
|
||||
WECHAT("wechat"),
|
||||
/**
|
||||
* QQ登录
|
||||
*/
|
||||
QQ("qq"),
|
||||
/**
|
||||
* 微博登录
|
||||
*/
|
||||
WEIBO("weibo"),
|
||||
/**
|
||||
* 支付宝登录
|
||||
*/
|
||||
ALIPAY("alipay"),
|
||||
/**
|
||||
* 钉钉登录
|
||||
*/
|
||||
DINGTALK("dingtalk"),
|
||||
/**
|
||||
* 企业微信登录
|
||||
*/
|
||||
WECHAT_ENTERPRISE("WECHAT_ENTERPRISE"),
|
||||
/**
|
||||
* Github
|
||||
*/
|
||||
GITHUB("github"),
|
||||
/**
|
||||
* Gitee
|
||||
*/
|
||||
GITEE("gitee"),
|
||||
/**
|
||||
* System
|
||||
*/
|
||||
SYSTEM("SYSTEM"),
|
||||
/**
|
||||
* 开源中国
|
||||
*/
|
||||
OSCHINA("OSCHINA"),
|
||||
/**
|
||||
* STACK_OVERFLOW
|
||||
*/
|
||||
STACK_OVERFLOW("STACK_OVERFLOW");
|
||||
|
||||
|
||||
public String type;
|
||||
|
||||
OauthType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public static OauthType getByType(String type) {
|
||||
for (OauthType resultKeyEnum : OauthType.values()) {
|
||||
if (resultKeyEnum.type.equals(type)) {
|
||||
return resultKeyEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package com.schisandra.auth.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Classname OauthType
|
||||
* @BelongsProject: schisandra-cloud-storage
|
||||
* @BelongsPackage: com.schisandra.auth.common.enums
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-05-26 13:36
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum OauthType {
|
||||
|
||||
/**
|
||||
* 微信登录
|
||||
*/
|
||||
WECHAT("wechat"),
|
||||
/**
|
||||
* QQ登录
|
||||
*/
|
||||
QQ("qq"),
|
||||
/**
|
||||
* 微博登录
|
||||
*/
|
||||
WEIBO("weibo"),
|
||||
/**
|
||||
* 支付宝登录
|
||||
*/
|
||||
ALIPAY("alipay"),
|
||||
/**
|
||||
* 钉钉登录
|
||||
*/
|
||||
DINGTALK("dingtalk"),
|
||||
/**
|
||||
* 企业微信登录
|
||||
*/
|
||||
WECHAT_ENTERPRISE("WECHAT_ENTERPRISE"),
|
||||
/**
|
||||
* Github
|
||||
*/
|
||||
GITHUB("github"),
|
||||
/**
|
||||
* Gitee
|
||||
*/
|
||||
GITEE("gitee"),
|
||||
/**
|
||||
* System
|
||||
*/
|
||||
SYSTEM("SYSTEM"),
|
||||
/**
|
||||
* 开源中国
|
||||
*/
|
||||
OSCHINA(""),
|
||||
/**
|
||||
* STACK_OVERFLOW
|
||||
*/
|
||||
STACK_OVERFLOW("STACK_OVERFLOW");
|
||||
|
||||
|
||||
public String type;
|
||||
|
||||
OauthType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public static OauthType getByType(String type) {
|
||||
for (OauthType resultKeyEnum : OauthType.values()) {
|
||||
if (resultKeyEnum.type.equals(type)) {
|
||||
return resultKeyEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user