1
0
mirror of synced 2026-04-27 03:58:53 +08:00

justauth-spring-boot-starter 完成~

This commit is contained in:
Yangkai.Shen
2019-07-22 15:23:07 +08:00
commit 78d8dccad8
9 changed files with 581 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
package com.xkcoding.justauth;
import com.xkcoding.justauth.properties.JustAuthProperties;
import lombok.RequiredArgsConstructor;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.request.*;
/**
* <p>
* AuthRequest工厂类
* </p>
*
* @author yangkai.shen
* @date Created in 2019-07-22 14:21
*/
@RequiredArgsConstructor
public class AuthRequestFactory {
private final JustAuthProperties properties;
/**
* 返回AuthRequest对象
*
* @param source {@link AuthSource}
* @return {@link AuthRequest}
*/
public AuthRequest get(AuthSource source) {
switch (source) {
case GITHUB:
return new AuthGithubRequest(properties.getType().get(source));
case WEIBO:
return new AuthWeiboRequest(properties.getType().get(source));
case GITEE:
return new AuthGiteeRequest(properties.getType().get(source));
case DINGTALK:
return new AuthDingTalkRequest(properties.getType().get(source));
case BAIDU:
return new AuthBaiduRequest(properties.getType().get(source));
case CSDN:
return new AuthCsdnRequest(properties.getType().get(source));
case CODING:
return new AuthCodingRequest(properties.getType().get(source));
case TENCENT_CLOUD:
return new AuthTencentCloudRequest(properties.getType().get(source));
case OSCHINA:
return new AuthOschinaRequest(properties.getType().get(source));
case ALIPAY:
return new AuthAlipayRequest(properties.getType().get(source));
case QQ:
return new AuthQqRequest(properties.getType().get(source));
case WECHAT:
return new AuthWeChatRequest(properties.getType().get(source));
case TAOBAO:
return new AuthTaobaoRequest(properties.getType().get(source));
case GOOGLE:
return new AuthGoogleRequest(properties.getType().get(source));
case FACEBOOK:
return new AuthFacebookRequest(properties.getType().get(source));
case DOUYIN:
return new AuthDouyinRequest(properties.getType().get(source));
case LINKEDIN:
return new AuthLinkedinRequest(properties.getType().get(source));
case MICROSOFT:
return new AuthMicrosoftRequest(properties.getType().get(source));
case MI:
return new AuthMiRequest(properties.getType().get(source));
case TOUTIAO:
return new AuthToutiaoRequest(properties.getType().get(source));
case TEAMBITION:
return new AuthTeambitionRequest(properties.getType().get(source));
case RENREN:
return new AuthRenrenRequest(properties.getType().get(source));
case PINTEREST:
return new AuthPinterestRequest(properties.getType().get(source));
case STACK_OVERFLOW:
return new AuthStackOverflowRequest(properties.getType().get(source));
default:
return null;
}
}
}

View File

@@ -0,0 +1,27 @@
package com.xkcoding.justauth;
import com.xkcoding.justauth.properties.JustAuthProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* <p>
* JustAuth 自动装配类
* </p>
*
* @author yangkai.shen
* @date Created in 2019-07-22 10:52
*/
@Configuration
@EnableConfigurationProperties(JustAuthProperties.class)
public class JustAuthAutoConfiguration {
@Bean
@ConditionalOnProperty(prefix = "justauth", value = "enabled", havingValue = "true", matchIfMissing = true)
public AuthRequestFactory authRequestFactory(JustAuthProperties properties) {
return new AuthRequestFactory(properties);
}
}

View File

@@ -0,0 +1,34 @@
package com.xkcoding.justauth.properties;
import lombok.Getter;
import lombok.Setter;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* JustAuth自动装配配置类
* </p>
*
* @author yangkai.shen
* @date Created in 2019-07-22 10:59
*/
@Getter
@Setter
@ConfigurationProperties(prefix = "justauth")
public class JustAuthProperties {
/**
* 是否启用 JustAuth
*/
private boolean enabled;
/**
* JustAuth 配置
*/
private Map<AuthSource, AuthConfig> type = new HashMap<>();
}

View File

@@ -0,0 +1,132 @@
{
"properties": [
{
"name": "justauth.type",
"type": "java.util.Map<me.zhyd.oauth.config.AuthSource,me.zhyd.oauth.config.AuthConfig>",
"description": "JustAuth 配置.",
"sourceType": "com.xkcoding.justauth.properties.JustAuthProperties"
}
],
"hints": [
{
"name": "justauth.type.keys",
"providers": [
{
"name": "handle-as",
"values": [
{
"value": "GITHUB",
"description": "GITHUB."
},
{
"value": "WEIBO",
"description": "WEIBO."
},
{
"value": "GITEE",
"description": "GITEE."
},
{
"value": "DINGTALK",
"description": "DINGTALK."
},
{
"value": "BAIDU",
"description": "BAIDU."
},
{
"value": "CSDN",
"description": "CSDN."
},
{
"value": "CODING",
"description": "CODING."
},
{
"value": "TENCENT_CLOUD",
"description": "TENCENT_CLOUD."
},
{
"value": "OSCHINA",
"description": "OSCHINA."
},
{
"value": "ALIPAY",
"description": "ALIPAY."
},
{
"value": "QQ",
"description": "QQ."
},
{
"value": "WECHAT",
"description": "WECHAT."
},
{
"value": "TAOBAO",
"description": "TAOBAO."
},
{
"value": "GOOGLE",
"description": "GOOGLE."
},
{
"value": "FACEBOOK",
"description": "FACEBOOK."
},
{
"value": "DOUYIN",
"description": "DOUYIN."
},
{
"value": "LINKEDIN",
"description": "LINKEDIN."
},
{
"value": "MICROSOFT",
"description": "MICROSOFT."
},
{
"value": "MI",
"description": "MI."
},
{
"value": "TOUTIAO",
"description": "TOUTIAO."
},
{
"value": "TEAMBITION",
"description": "TEAMBITION."
},
{
"value": "RENREN",
"description": "RENREN."
},
{
"value": "PINTEREST",
"description": "PINTEREST."
},
{
"value": "STACK_OVERFLOW",
"description": "STACK_OVERFLOW."
}
],
"parameters": {
"target": "me.zhyd.oauth.config.AuthSource"
}
}
]
},
{
"name": "justauth.type.values",
"providers": [
{
"name": "handle-as",
"parameters": {
"target": "me.zhyd.oauth.config.AuthConfig"
}
}
]
}
]
}

View File

@@ -0,0 +1 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.xkcoding.justauth.JustAuthAutoConfiguration