Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b45e9ab43d | ||
|
|
4233902219 | ||
|
|
7f04dd3bfd | ||
|
|
b24d490024 | ||
|
|
4250bdcf0c | ||
|
|
be41025184 | ||
|
|
e283b4731a | ||
|
|
155786d42d | ||
|
|
b2c718268c | ||
|
|
477805e824 | ||
|
|
54cad5e128 | ||
|
|
23b781797c | ||
|
|
ce34663f92 | ||
|
|
6971ae0387 | ||
|
|
8a49350b61 | ||
|
|
a82d6b6387 | ||
|
|
2a593a2770 | ||
|
|
57e040c99f | ||
|
|
a1bbe95fea | ||
|
|
d08c2101cf |
65
.github/workflows/deploy-snapshot.yml
vendored
Normal file
65
.github/workflows/deploy-snapshot.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ dev ]
|
||||
paths:
|
||||
- src/**
|
||||
- pom.xml
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- name: Set up Java and Maven
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
- name: Cache m2 package
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- run: mvn test
|
||||
|
||||
deploy-snapshot:
|
||||
needs: test
|
||||
if: ${{ success() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- name: Set up Java and Maven
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
server-id: ossrh
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
- name: Cache m2 package
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: setting snapshot version
|
||||
run: |
|
||||
import xml.etree.ElementTree as ET
|
||||
tree = ET.parse("pom.xml")
|
||||
version = tree.find("{http://maven.apache.org/POM/4.0.0}version")
|
||||
print(version.text + "-SNAPSHOT")
|
||||
if version.text.endswith("-SNAPSHOT") == False:
|
||||
tree.find("{http://maven.apache.org/POM/4.0.0}version").text = version.text + "-SNAPSHOT"
|
||||
ET.register_namespace("", "http://maven.apache.org/POM/4.0.0")
|
||||
tree.write("pom.xml", "utf-8", True)
|
||||
shell: python
|
||||
- name: deploy snapshot to ossrh repository
|
||||
run: mvn -B deploy -P snapshot -DskipTests
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
26
.github/workflows/test-pr.yml
vendored
Normal file
26
.github/workflows/test-pr.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: test pull_request
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- src/**
|
||||
- pom.xml
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- name: Set up Java and Maven
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
- name: Cache m2 package
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- run: mvn test
|
||||
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,5 +1,28 @@
|
||||
## 版本更新记录
|
||||
|
||||
### 【1.4.0】2021-05-10
|
||||
|
||||
- 升级 `JustAuth` 版本:1.16.1,新增Amazon、Slack、LINE、Okta、钉钉账号登录,同时修复若干BUG,详细信息请参考参考:https://github.com/justauth/JustAuth/blob/master/CHANGELOGS.md#1161
|
||||
- 升级 `hutool-core` 版本:5.6.5
|
||||
|
||||
### 【1.3.5】2021-01-04
|
||||
|
||||
- 升级 `JustAuth` 版本:1.15.9,新增飞书、京东、阿里云、喜马拉雅、企业微信网页端登录
|
||||
- 升级 `hutool-core` 版本:5.5.6
|
||||
|
||||
### 【1.3.4】2020-09-12
|
||||
|
||||
- 升级 `JustAuth` 版本:1.15.7,更新最新的 GitHub API
|
||||
|
||||
### 【1.3.4.beta】2020-08-29
|
||||
|
||||
- 升级 `JustAuth` 版本:1.15.7-beta.3,支持自定义 http config 以及自定义 scopes
|
||||
- 升级 `hutool-core` 版本:5.4.0,修复 `JSONUtil.toJsonStr(obj)` 报错的问题,参见 [ISSUE#8](https://github.com/justauth/justauth-spring-boot-starter/issues/8)
|
||||
|
||||
### 【1.3.3】2020-04-13
|
||||
|
||||
- 升级 `JustAuth` 版本:1.15.1
|
||||
|
||||
### 【1.3.2】2019-12-25
|
||||
|
||||
- 升级 `JustAuth` 版本:1.13.2,新增微信公众号登录,区分之前的开放平台登录
|
||||
|
||||
241
README.md
241
README.md
@@ -28,12 +28,21 @@ https://github.com/xkcoding/justauth-spring-boot-starter-demo
|
||||
<dependency>
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- 添加配置,在 `application.yml` 中添加配置配置信息
|
||||
|
||||
注意:
|
||||
|
||||
- `justauth.type`节点的配置,请根据项目实际情况选择,多余的可以删除
|
||||
- 如果使用 QQ 登录,并且需要获取`unionId`,则必须传`union-id`配置,并置为`true`
|
||||
- 如果使用支付宝登录,必传`alipay-public-key`
|
||||
- 如果使用 Stack Overflow 登录,必传`stack-overflow-key`
|
||||
- 如果使用企业微信登录,必传`agent-id`
|
||||
- 如果使用 CODING 登录,必传`coding-group-name`
|
||||
|
||||
```yaml
|
||||
justauth:
|
||||
enabled: true
|
||||
@@ -42,10 +51,151 @@ 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
|
||||
coding-group-name: xx
|
||||
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
|
||||
XMLY:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/xmly/callback
|
||||
# 设备唯一标识ID
|
||||
device-id: xxxxxxxxxxxxxx
|
||||
# 客户端操作系统类型,1-iOS系统,2-Android系统,3-Web
|
||||
client-os-type: 3
|
||||
# 客户端包名,如果 clientOsType 为1或2时必填。对Android客户端是包名,对IOS客户端是Bundle ID
|
||||
#pack-id: xxxx
|
||||
FEISHU:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/feishu/callback
|
||||
JD:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/jd/callback
|
||||
cache:
|
||||
type: default
|
||||
```
|
||||
|
||||
|
||||
|
||||
- 然后就开始玩耍吧~
|
||||
|
||||
```java
|
||||
@@ -388,27 +538,98 @@ justauth:
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/test/callback
|
||||
```
|
||||
|
||||
## 4. 附录
|
||||
## 4. http 代理配置
|
||||
|
||||
### 4.1. 基础配置
|
||||
修改配置文件,增加如下配置:
|
||||
|
||||
#### 4.1.1. `justauth` 配置列表
|
||||
```yaml
|
||||
justauth:
|
||||
http-config:
|
||||
timeout: 30000
|
||||
proxy:
|
||||
GOOGLE:
|
||||
type: HTTP
|
||||
hostname: 127.0.0.1
|
||||
port: 10080
|
||||
```
|
||||
|
||||
注:当项目中使用了自定义的第三方登录,并且需要使用代理时,也要在 `http-config` 节点下添加相关配置,格式参考上面示例
|
||||
|
||||
## 5. 自定义 Scopes
|
||||
|
||||
修改配置文件,增加如下配置:
|
||||
|
||||
```yml
|
||||
justauth:
|
||||
enabled: true
|
||||
type:
|
||||
QQ:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: http://oauth.xkcoding.com/demo/oauth/qq/callback
|
||||
union-id: false
|
||||
scopes:
|
||||
- get_user_info
|
||||
- xxxx
|
||||
```
|
||||
|
||||
注:你可以前往 `me.zhyd.oauth.enums.scope` 包下查看各个渠道所支持的 scopes,当然你可以不配置该项,JustAuth 会默认添加上一些基础 scope
|
||||
|
||||
## 6. 附录
|
||||
|
||||
### 6.1. `justauth` 配置列表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 可选项 | 描述 |
|
||||
| ------------------ | ------------------------------------------------------------ | ------ | ---------- | ---------------------- |
|
||||
| `justauth.enabled` | `boolean` | true | true/false | 是否启用 JustAuth |
|
||||
| `justauth.type` | `java.util.Map<me.zhyd.oauth.config.AuthSource,me.zhyd.oauth.config.AuthConfig>` | 无 | | JustAuth 配置 |
|
||||
| `justauth.httpConfig` | `java.util.Map<me.zhyd.oauth.config.AuthSource,com.xkcoding.justauth.autoconfigure.JustAuthProperties.JustAuthHttpConfig>` | 无 | | http 相关配置 |
|
||||
| `justauth.cache` | `com.xkcoding.justauth.autoconfigure.CacheProperties` | | | JustAuth缓存配置 |
|
||||
| `justauth.extend` | `com.xkcoding.justauth.autoconfigure.ExtendProperties` | 无 | | JustAuth第三方平台配置 |
|
||||
|
||||
##### 4.1.1.1. `justauth.type` 配置列表
|
||||
#### `justauth.type` 配置列表
|
||||
|
||||
| 属性名 | 描述 |
|
||||
| --------------------------- | ------------------------------------------------------------ |
|
||||
| `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.2.`justauth.cache` 配置列表
|
||||
##### `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 | 当使用企业微信登录时, **该值必填** |
|
||||
| `coding-group-name` | 团队域名前缀 | 使用 Coding 登录时, **该值必填** |
|
||||
|
||||
#### `justauth.httpConfig` 配置列表
|
||||
|
||||
| 属性名 | 描述 |
|
||||
| --------------------------- | ------------------------------------------------------------ |
|
||||
| `justauth.httpConfig.keys` | `justauth.type` 是 `Map` 格式的,key 的取值请参考 [`AuthDefaultSource`](https://github.com/zhangyd-c/JustAuth/blob/master/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java) |
|
||||
| `justauth.httpConfig.keys.values` | `justauth.type` 是 `Map` 格式的,value 的取值请参考 `JustAuthProperties.JustAuthHttpConfig` |
|
||||
|
||||
##### `justauth.httpConfig.keys.values` 所有可选配置如下:
|
||||
|
||||
| 属性名 | 描述 | 备注 |
|
||||
| --------------------------- | ----------------------------------------------------------- | ------------------------------- |
|
||||
| `timeout` | 请求超时时间 | |
|
||||
| `proxy` | 代理的相关配置,针对国外平台,需要配置代理 | **必填** |
|
||||
|
||||
##### `justauth.httpConfig.proxy` 所有可选配置如下:
|
||||
|
||||
| 属性名 | 描述 | 备注 |
|
||||
| --------------------------- | ----------------------------------------------------------- | ------------------------------- |
|
||||
| `type` | 代理类型,可选值:`HTTP`、`DIRECT`、`SOCKS`,默认为 `HTTP` | |
|
||||
| `hostname` | 代理 IP 地址 | |
|
||||
| `port` | 代理端口 | |
|
||||
|
||||
#### `justauth.cache` 配置列表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 可选项 | 描述 |
|
||||
| ------------------------ | ------------------------------------------------------------ | ----------------- | -------------------- | ------------------------------------------------------------ |
|
||||
@@ -416,21 +637,21 @@ justauth:
|
||||
| `justauth.cache.prefix` | `java.lang.String` | JUSTAUTH::STATE:: | | 缓存前缀,目前只对redis缓存生效,默认 `JUSTAUTH::STATE::` |
|
||||
| `justauth.cache.timeout` | `java.time.Duration` | 3分钟 | | 超时时长,目前只对redis缓存生效,默认`3分钟` |
|
||||
|
||||
##### 4.1.1.3.`justauth.extend` 配置列表
|
||||
#### `justauth.extend` 配置列表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 可选项 | 描述 |
|
||||
| ---------------------------- | -------------------------------------------- | ------ | ------ | ------------ |
|
||||
| `justauth.extend.enum-class` | `Class<? extends AuthSource>` | 无 | | 枚举类全路径 |
|
||||
| `justauth.extend.config` | `java.util.Map<String, ExtendRequestConfig>` | 无 | | 对应配置信息 |
|
||||
|
||||
###### 4.1.1.3.1.`justauth.extend.config` 配置列表
|
||||
##### `justauth.extend.config` 配置列表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 可选项 | 描述 |
|
||||
| ------------------------------- | ------------------------------------------------------------ | ------ | ------ | ------------------------------------------------------------ |
|
||||
| `justauth.extend.config.keys` | `java.lang.String` | 无 | | key 必须在 `justauth.extend.enum-class` 配置的枚举类中声明 |
|
||||
| `justauth.extend.config.values` | `com.xkcoding.justauth.autoconfigure.ExtendProperties.ExtendRequestConfig` | 无 | | value 就是 `AuthConfig` 的子类,增加了一个 `request-class` 属性配置请求的全类名,具体参考类[`ExtendProperties.ExtendRequestConfig`](https://github.com/justauth/justauth-spring-boot-starter/blob/master/src/main/java/com/xkcoding/justauth/autoconfigure/ExtendProperties.java#L49-L54) |
|
||||
|
||||
### 4.2. SNAPSHOT版本
|
||||
### 6.2. SNAPSHOT版本
|
||||
|
||||
如果需要体验快照版本,可以在你的 `pom.xml`进行如下配置:
|
||||
|
||||
|
||||
35
pom.xml
35
pom.xml
@@ -23,7 +23,7 @@
|
||||
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>1.4.0</version>
|
||||
|
||||
<name>justauth-spring-boot-starter</name>
|
||||
<url>https://github.com/xkcoding/justauth-spring-boot-starter</url>
|
||||
@@ -43,6 +43,11 @@
|
||||
</roles>
|
||||
<timezone>Asia/Shanghai</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Yadong.Zhang</name>
|
||||
<email>yadong.zhang0415@gmail.com</email>
|
||||
<url>https://www.zhyd.me</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
@@ -67,10 +72,16 @@
|
||||
<!--SpringBoot版本-->
|
||||
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
|
||||
<!--JustAuth版本-->
|
||||
<justauth.version>1.13.2</justauth.version>
|
||||
<justauth.version>1.16.1</justauth.version>
|
||||
<hutool.version>5.6.5</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 +90,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>
|
||||
@@ -204,6 +215,15 @@
|
||||
</repositories>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>snapshot</id>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
@@ -225,14 +245,9 @@
|
||||
</plugins>
|
||||
</build>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>oss</id>
|
||||
<name>Oss Release Repository</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>oss</id>
|
||||
<name>Oss Snapshot Repository</name>
|
||||
<name>Oss Release Repository</name>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
@@ -21,6 +21,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
import com.xkcoding.justauth.autoconfigure.ExtendProperties;
|
||||
import com.xkcoding.justauth.autoconfigure.JustAuthProperties;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,7 +33,10 @@ import me.zhyd.oauth.config.AuthSource;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.request.*;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -58,10 +62,10 @@ public class AuthRequestFactory {
|
||||
*
|
||||
* @return Oauth列表
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public List<String> oauthList() {
|
||||
// 默认列表
|
||||
List<String> defaultList = properties.getType().keySet().stream().map(Enum::name).collect(Collectors.toList());
|
||||
List<String> defaultList = new ArrayList<>(properties.getType().keySet());
|
||||
// 扩展列表
|
||||
List<String> extendList = new ArrayList<>();
|
||||
ExtendProperties extend = properties.getExtend();
|
||||
@@ -114,10 +118,11 @@ public class AuthRequestFactory {
|
||||
* @param source {@link AuthSource}
|
||||
* @return {@link AuthRequest}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private AuthRequest getExtendRequest(Class clazz, String source) {
|
||||
String upperSource = source.toUpperCase();
|
||||
try {
|
||||
EnumUtil.fromString(clazz, source.toUpperCase());
|
||||
EnumUtil.fromString(clazz, upperSource);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// 无自定义匹配
|
||||
return null;
|
||||
@@ -129,8 +134,12 @@ public class AuthRequestFactory {
|
||||
Map<String, ExtendProperties.ExtendRequestConfig> upperConfig = new HashMap<>(6);
|
||||
extendConfig.forEach((k, v) -> upperConfig.put(k.toUpperCase(), v));
|
||||
|
||||
ExtendProperties.ExtendRequestConfig extendRequestConfig = upperConfig.get(source.toUpperCase());
|
||||
ExtendProperties.ExtendRequestConfig extendRequestConfig = upperConfig.get(upperSource);
|
||||
if (extendRequestConfig != null) {
|
||||
|
||||
// 配置 http config
|
||||
configureHttpConfig(upperSource, extendRequestConfig, properties.getHttpConfig());
|
||||
|
||||
Class<? extends AuthRequest> requestClass = extendRequestConfig.getRequestClass();
|
||||
|
||||
if (requestClass != null) {
|
||||
@@ -159,12 +168,15 @@ public class AuthRequestFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
AuthConfig config = properties.getType().get(authDefaultSource);
|
||||
AuthConfig config = properties.getType().get(authDefaultSource.name());
|
||||
// 找不到对应关系,直接返回空
|
||||
if (config == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 配置 http config
|
||||
configureHttpConfig(authDefaultSource.name(), config, properties.getHttpConfig());
|
||||
|
||||
switch (authDefaultSource) {
|
||||
case GITHUB:
|
||||
return new AuthGithubRequest(config, authStateCache);
|
||||
@@ -174,26 +186,28 @@ public class AuthRequestFactory {
|
||||
return new AuthGiteeRequest(config, authStateCache);
|
||||
case DINGTALK:
|
||||
return new AuthDingTalkRequest(config, authStateCache);
|
||||
case DINGTALK_ACCOUNT:
|
||||
return new AuthDingTalkAccountRequest(config, authStateCache);
|
||||
case BAIDU:
|
||||
return new AuthBaiduRequest(config, authStateCache);
|
||||
case CSDN:
|
||||
return new AuthCsdnRequest(config, authStateCache);
|
||||
case CODING:
|
||||
return new AuthCodingRequest(config, authStateCache);
|
||||
case TENCENT_CLOUD:
|
||||
return new AuthTencentCloudRequest(config, authStateCache);
|
||||
case OSCHINA:
|
||||
return new AuthOschinaRequest(config, authStateCache);
|
||||
case ALIPAY:
|
||||
return new AuthAlipayRequest(config, authStateCache);
|
||||
case QQ:
|
||||
return new AuthQqRequest(config, authStateCache);
|
||||
case WECHAT_MP:
|
||||
return new AuthWeChatMpRequest(config, authStateCache);
|
||||
case WECHAT_OPEN:
|
||||
return new AuthWeChatOpenRequest(config, authStateCache);
|
||||
case WECHAT_MP:
|
||||
return new AuthWeChatMpRequest(config, authStateCache);
|
||||
case WECHAT_ENTERPRISE:
|
||||
return new AuthWeChatEnterpriseRequest(config, authStateCache);
|
||||
return new AuthWeChatEnterpriseQrcodeRequest(config, authStateCache);
|
||||
case WECHAT_ENTERPRISE_WEB:
|
||||
return new AuthWeChatEnterpriseWebRequest(config, authStateCache);
|
||||
case TAOBAO:
|
||||
return new AuthTaobaoRequest(config, authStateCache);
|
||||
case GOOGLE:
|
||||
@@ -230,8 +244,50 @@ public class AuthRequestFactory {
|
||||
return new AuthMeituanRequest(config, authStateCache);
|
||||
case TWITTER:
|
||||
return new AuthTwitterRequest(config, authStateCache);
|
||||
case FEISHU:
|
||||
return new AuthFeishuRequest(config, authStateCache);
|
||||
case JD:
|
||||
return new AuthJdRequest(config, authStateCache);
|
||||
case ALIYUN:
|
||||
return new AuthAliyunRequest(config, authStateCache);
|
||||
case XMLY:
|
||||
return new AuthXmlyRequest(config, authStateCache);
|
||||
case AMAZON:
|
||||
return new AuthAmazonRequest(config, authStateCache);
|
||||
case SLACK:
|
||||
return new AuthSlackRequest(config, authStateCache);
|
||||
case LINE:
|
||||
return new AuthLineRequest(config, authStateCache);
|
||||
case OKTA:
|
||||
return new AuthOktaRequest(config, authStateCache);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置 http 相关的配置
|
||||
*
|
||||
* @param authSource {@link AuthSource}
|
||||
* @param authConfig {@link AuthConfig}
|
||||
*/
|
||||
private void configureHttpConfig(String authSource, AuthConfig authConfig, JustAuthProperties.JustAuthHttpConfig httpConfig) {
|
||||
if (null == httpConfig) {
|
||||
return;
|
||||
}
|
||||
Map<String, JustAuthProperties.JustAuthProxyConfig> proxyConfigMap = httpConfig.getProxy();
|
||||
if (CollectionUtils.isEmpty(proxyConfigMap)) {
|
||||
return;
|
||||
}
|
||||
JustAuthProperties.JustAuthProxyConfig proxyConfig = proxyConfigMap.get(authSource);
|
||||
|
||||
if (null == proxyConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
authConfig.setHttpConfig(HttpConfig.builder()
|
||||
.timeout(httpConfig.getTimeout())
|
||||
.proxy(new Proxy(Proxy.Type.valueOf(proxyConfig.getType()), new InetSocketAddress(proxyConfig.getHostname(), proxyConfig.getPort())))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,6 @@ public class CacheProperties {
|
||||
/**
|
||||
* 自定义缓存
|
||||
*/
|
||||
CUSTOM;
|
||||
CUSTOM
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ExtendProperties {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ExtendRequestConfig extends AuthConfig{
|
||||
public static class ExtendRequestConfig extends AuthConfig {
|
||||
/**
|
||||
* 请求对应全路径
|
||||
*/
|
||||
|
||||
@@ -20,10 +20,10 @@ package com.xkcoding.justauth.autoconfigure;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -47,7 +47,13 @@ public class JustAuthProperties {
|
||||
/**
|
||||
* JustAuth 默认配置
|
||||
*/
|
||||
private Map<AuthDefaultSource, AuthConfig> type = new HashMap<>();
|
||||
private Map<String, AuthConfig> type = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* http 相关的配置,可设置请求超时时间和代理配置
|
||||
*/
|
||||
private JustAuthHttpConfig httpConfig;
|
||||
|
||||
/**
|
||||
* JustAuth 自定义配置
|
||||
@@ -61,4 +67,19 @@ public class JustAuthProperties {
|
||||
@NestedConfigurationProperty
|
||||
private CacheProperties cache = new CacheProperties();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class JustAuthProxyConfig {
|
||||
private String type = Proxy.Type.HTTP.name();
|
||||
private String hostname;
|
||||
private int port;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class JustAuthHttpConfig {
|
||||
private int timeout;
|
||||
private Map<String, JustAuthProxyConfig> proxy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,119 +1,139 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "justauth.type",
|
||||
"type": "java.util.Map<me.zhyd.oauth.config.AuthSource,me.zhyd.oauth.config.AuthConfig>",
|
||||
"description": "JustAuth 配置.",
|
||||
"sourceType": "com.xkcoding.justauth.autoconfigure.JustAuthProperties"
|
||||
}
|
||||
],
|
||||
"hints": [
|
||||
{
|
||||
"name": "justauth.type.keys",
|
||||
"providers": [
|
||||
"values": [
|
||||
{
|
||||
"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"
|
||||
}
|
||||
"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": "OSCHINA",
|
||||
"description": "OSCHINA."
|
||||
},
|
||||
{
|
||||
"value": "ALIPAY",
|
||||
"description": "ALIPAY."
|
||||
},
|
||||
{
|
||||
"value": "QQ",
|
||||
"description": "QQ."
|
||||
},
|
||||
{
|
||||
"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."
|
||||
},
|
||||
{
|
||||
"value": "HUAWEI",
|
||||
"description": "HUAWEI."
|
||||
},
|
||||
{
|
||||
"value": "WECHAT_OPEN",
|
||||
"description": "WeChat open platform."
|
||||
},
|
||||
{
|
||||
"value": "WECHAT_ENTERPRISE",
|
||||
"description": "WeChat enterprise platform."
|
||||
},
|
||||
{
|
||||
"value": "WECHAT_MP",
|
||||
"description": "WeChat Official Platform."
|
||||
},
|
||||
{
|
||||
"value": "KUJIALE",
|
||||
"description": "KUJIALE."
|
||||
},
|
||||
{
|
||||
"value": "GITLAB",
|
||||
"description": "GITLAB."
|
||||
},
|
||||
{
|
||||
"value": "MEITUAN",
|
||||
"description": "MEITUAN."
|
||||
},
|
||||
{
|
||||
"value": "ELEME",
|
||||
"description": "ELEME."
|
||||
},
|
||||
{
|
||||
"value": "GITLAB",
|
||||
"description": "GITLAB."
|
||||
},
|
||||
{
|
||||
"value": "TWITTER",
|
||||
"description": "TWITTER."
|
||||
},
|
||||
{
|
||||
"value": "ALIYUN",
|
||||
"description": "ALIYUN."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user