Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a593a2770 | ||
|
|
57e040c99f | ||
|
|
a1bbe95fea | ||
|
|
d08c2101cf | ||
|
|
019839782a | ||
|
|
b484c0993f | ||
|
|
ce8203401c | ||
|
|
248ec4fc4d | ||
|
|
8a2f4067c2 | ||
|
|
13fd792521 | ||
|
|
03649eb5c3 | ||
|
|
a8b8dee49f | ||
|
|
2de415c7ba | ||
|
|
c670d9d10a | ||
|
|
dea73c1c6e | ||
|
|
64a389aac4 | ||
|
|
e07cb8970b | ||
|
|
1a690f5dd1 | ||
|
|
2029083f26 | ||
|
|
c00a127011 | ||
|
|
6b99039b98 |
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,5 +1,22 @@
|
||||
## 版本更新记录
|
||||
|
||||
### 【1.3.3】2020-04-13
|
||||
|
||||
- 升级 `JustAuth` 版本:1.15.1
|
||||
|
||||
### 【1.3.2】2019-12-25
|
||||
|
||||
- 升级 `JustAuth` 版本:1.13.2,新增微信公众号登录,区分之前的开放平台登录
|
||||
|
||||
### 【1.3.1】2019-11-12
|
||||
|
||||
- 升级 `JustAuth` 版本:1.13.1,修复 `AuthCallback` 异常的问题,参见 [ISSUE#52](https://github.com/justauth/JustAuth/issues/52)
|
||||
|
||||
### 【1.3.0】2019-11-04
|
||||
|
||||
- 修改 `groupId` 为 `com.xkcoding.justauth`
|
||||
- 升级 `JustAuth` 版本:1.13.0,支持 `推特`
|
||||
|
||||
### 【1.2.1】2019-10-12
|
||||
|
||||
- 紧急修复Oauth列表空指针BUG
|
||||
|
||||
156
README.md
156
README.md
@@ -4,7 +4,7 @@
|
||||
>
|
||||
> JustAuth 脚手架
|
||||
|
||||

|
||||

|
||||
|
||||
## 1. Demo
|
||||
|
||||
@@ -26,14 +26,22 @@ https://github.com/xkcoding/justauth-spring-boot-starter-demo
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.xkcoding</groupId>
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.3.3</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- 添加配置,在 `application.yml` 中添加配置配置信息
|
||||
|
||||
注意:
|
||||
|
||||
- `justauth.type`节点的配置,请根据项目实际情况选择,多余的可以删除
|
||||
- 如果使用QQ登录,并且需要获取`unionId`,则必须传`union-id`配置,并置为`true`
|
||||
- 如果使用支付宝登录,必传`alipay-public-key`
|
||||
- 如果使用Stack Overflow登录,必传`stack-overflow-key`
|
||||
- 如果使用企业微信登录,必传`agent-id`
|
||||
|
||||
```yaml
|
||||
justauth:
|
||||
enabled: true
|
||||
@@ -42,10 +50,136 @@ justauth:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/qq/callback
|
||||
union-id: false
|
||||
WEIBO:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/weibo/callback
|
||||
GITEE:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/gitee/callback
|
||||
DINGTALK:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/dingtalk/callback
|
||||
BAIDU:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/baidu/callback
|
||||
CSDN:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/csdn/callback
|
||||
CODING:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/coding/callback
|
||||
TENCENT_CLOUD:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/tencent_cloud/callback
|
||||
OSCHINA:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/oschina/callback
|
||||
ALIPAY:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/alipay/callback
|
||||
alipay-public-key: MIIB**************DAQAB
|
||||
WECHAT_OPEN:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/wechat_open/callback
|
||||
WECHAT_MP:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/wechat_mp/callback
|
||||
WECHAT_ENTERPRISE:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/wechat_enterprise/callback
|
||||
agent-id: 1000002
|
||||
TAOBAO:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/taobao/callback
|
||||
GOOGLE:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/google/callback
|
||||
FACEBOOK:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/facebook/callback
|
||||
DOUYIN:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/douyin/callback
|
||||
LINKEDIN:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/linkedin/callback
|
||||
MICROSOFT:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/microsoft/callback
|
||||
MI:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/mi/callback
|
||||
TOUTIAO:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/toutiao/callback
|
||||
TEAMBITION:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/teambition/callback
|
||||
RENREN:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/renren/callback
|
||||
PINTEREST:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/pinterest/callback
|
||||
STACK_OVERFLOW:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/stack_overflow/callback
|
||||
stack-overflow-key: asd*********asd
|
||||
HUAWEI:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/huawei/callback
|
||||
KUJIALE:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/kujiale/callback
|
||||
GITLAB:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/gitlab/callback
|
||||
MEITUAN:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/meituan/callback
|
||||
ELEME:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/eleme/callback
|
||||
TWITTER:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/twitter/callback
|
||||
cache:
|
||||
type: default
|
||||
```
|
||||
|
||||
|
||||
|
||||
- 然后就开始玩耍吧~
|
||||
|
||||
```java
|
||||
@@ -405,9 +539,21 @@ justauth:
|
||||
|
||||
| 属性名 | 描述 |
|
||||
| --------------------------- | ------------------------------------------------------------ |
|
||||
| `justauth.type.keys` | `justauth.type` 是 `Map` 格式的,key 的取值请参考 [`AuthSource`](https://github.com/zhangyd-c/JustAuth/blob/master/src/main/java/me/zhyd/oauth/config/AuthSource.java) |
|
||||
| `justauth.type.keys` | `justauth.type` 是 `Map` 格式的,key 的取值请参考 [`AuthDefaultSource`](https://github.com/zhangyd-c/JustAuth/blob/master/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java) |
|
||||
| `justauth.type.keys.values` | `justauth.type` 是 `Map` 格式的,value 的取值请参考 [`AuthConfig`](https://github.com/zhangyd-c/JustAuth/blob/master/src/main/java/me/zhyd/oauth/config/AuthConfig.java) |
|
||||
|
||||
###### 4.1.1.1.1 `justauth.type.keys.values` 所有可选配置如下:
|
||||
|
||||
| 属性名 | 描述 | 备注 |
|
||||
| --------------------------- | ----------------------------------------------------------- | ------------------------------- |
|
||||
| `client-id` | 客户端id,对应各平台的appKey | 必填 |
|
||||
| `client-secret` | 客户端Secret,对应各平台的appSecret | 必填 |
|
||||
| `redirect-uri` | 登录成功后的回调地址 | 必填 |
|
||||
| `alipay-public-key` | 支付宝公钥 | 当使用支付宝登录时,该值必填,对应“RSA2(SHA256)密钥”中的“支付宝公钥” |
|
||||
| `union-id` | 是否需要申请unionid | 当使用QQ登录时,该值**选填**,如果置为`true`则qq开发者应用必须具备相应权限,参考链接:[查看详情](http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D) |
|
||||
| `stack-overflow-key` | Stack Overflow Key | 当使用Stack Overflow登录时,该值必填 |
|
||||
| `agent-id` | 企业微信,授权方的网页应用ID | 当使用企业微信登录时,该值必填 |
|
||||
|
||||
##### 4.1.1.2.`justauth.cache` 配置列表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 可选项 | 描述 |
|
||||
@@ -432,7 +578,7 @@ justauth:
|
||||
|
||||
### 4.2. SNAPSHOT版本
|
||||
|
||||
如果需要体验快照版本,可以在你的 `pom.xml`进行如下配置:
|
||||
如果需要体验快照版本,可以在你的 `pom.xml`进行如下配置:
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
|
||||
16
pom.xml
16
pom.xml
@@ -21,9 +21,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.xkcoding</groupId>
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.3.3</version>
|
||||
|
||||
<name>justauth-spring-boot-starter</name>
|
||||
<url>https://github.com/xkcoding/justauth-spring-boot-starter</url>
|
||||
@@ -67,10 +67,16 @@
|
||||
<!--SpringBoot版本-->
|
||||
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
|
||||
<!--JustAuth版本-->
|
||||
<justauth.version>1.12.0</justauth.version>
|
||||
<justauth.version>1.15.1</justauth.version>
|
||||
<hutool.version>5.1.0</hutool.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
@@ -79,13 +85,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- 对象池,使用redis时必须引入 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -65,11 +65,16 @@ public class AuthRequestFactory {
|
||||
// 扩展列表
|
||||
List<String> extendList = new ArrayList<>();
|
||||
ExtendProperties extend = properties.getExtend();
|
||||
if (null != extend){
|
||||
if (null != extend) {
|
||||
Class enumClass = extend.getEnumClass();
|
||||
List<String> names = EnumUtil.getNames(enumClass);
|
||||
// 扩展列表
|
||||
extendList = extend.getConfig().keySet().stream().filter(x -> names.contains(x.toUpperCase())).map(String::toUpperCase).collect(Collectors.toList());
|
||||
extendList = extend.getConfig()
|
||||
.keySet()
|
||||
.stream()
|
||||
.filter(x -> names.contains(x.toUpperCase()))
|
||||
.map(String::toUpperCase)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 合并
|
||||
@@ -183,8 +188,12 @@ public class AuthRequestFactory {
|
||||
return new AuthAlipayRequest(config, authStateCache);
|
||||
case QQ:
|
||||
return new AuthQqRequest(config, authStateCache);
|
||||
case WECHAT:
|
||||
return new AuthWeChatRequest(config, authStateCache);
|
||||
case WECHAT_MP:
|
||||
return new AuthWeChatMpRequest(config, authStateCache);
|
||||
case WECHAT_OPEN:
|
||||
return new AuthWeChatOpenRequest(config, authStateCache);
|
||||
case WECHAT_ENTERPRISE:
|
||||
return new AuthWeChatEnterpriseRequest(config, authStateCache);
|
||||
case TAOBAO:
|
||||
return new AuthTaobaoRequest(config, authStateCache);
|
||||
case GOOGLE:
|
||||
@@ -211,8 +220,6 @@ public class AuthRequestFactory {
|
||||
return new AuthStackOverflowRequest(config, authStateCache);
|
||||
case HUAWEI:
|
||||
return new AuthHuaweiRequest(config, authStateCache);
|
||||
case WECHAT_ENTERPRISE:
|
||||
return new AuthWeChatEnterpriseRequest(config, authStateCache);
|
||||
case GITLAB:
|
||||
return new AuthGitlabRequest(config, authStateCache);
|
||||
case KUJIALE:
|
||||
@@ -221,6 +228,8 @@ public class AuthRequestFactory {
|
||||
return new AuthElemeRequest(config, authStateCache);
|
||||
case MEITUAN:
|
||||
return new AuthMeituanRequest(config, authStateCache);
|
||||
case TWITTER:
|
||||
return new AuthTwitterRequest(config, authStateCache);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ abstract class JustAuthStateCacheConfiguration {
|
||||
log.debug("JustAuth 使用 Redis 缓存存储 state 数据");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Bean(name = "justAuthRedisCacheTemplate")
|
||||
public RedisTemplate<String, String> justAuthRedisCacheTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, String> template = new RedisTemplate<>();
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
|
||||
Reference in New Issue
Block a user