Skip to content

Commit

Permalink
🔖 1.15.5-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyd-c committed Jun 7, 2020
1 parent 571c343 commit e93ad07
Show file tree
Hide file tree
Showing 44 changed files with 453 additions and 214 deletions.
8 changes: 4 additions & 4 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven%20Central--1.15.4-alpha-blue" ></img>
<img src="https://img.shields.io/badge/Maven%20Central--1.15.5-alpha-blue" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
Expand All @@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api%20Docs--1.15.4-alpha-latest-orange" ></img>
<img src="https://img.shields.io/badge/Api%20Docs--1.15.5-alpha-latest-orange" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
Expand Down Expand Up @@ -97,7 +97,7 @@ These artifacts are available from Maven Central:
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.15.4-alpha</version>
<version>1.15.5-alpha</version>
</dependency>
```
- Using JustAuth
Expand Down Expand Up @@ -182,7 +182,7 @@ Note, that since [v1.14.0](https://gitee.com/yadong.zhang/JustAuth/releases/v1.1
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png" width="20"> | [AuthDouyinRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java) | <a href="https://www.douyin.com/platform/doc/m-2-1-1" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png" width="20"> | [AuthLinkedinRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java) | <a href="https://docs.microsoft.com/zh-cn/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png" width="20"> | [AuthMicrosoftRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java) | <a href="https://docs.microsoft.com/zh-cn/graph/auth/" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png" width="20"> | [AuthMicrosoftRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java) | <a href="https://docs.microsoft.com/zh-cn/graph/auth-v2-user" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png" width="20"> | [AuthMiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java) | <a href="https://dev.mi.com/console/doc/detail?pId=711" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/toutiao.png" width="20"> | [AuthToutiaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java) | <a href="https://open.mp.toutiao.com/#/resource?_k=y7mfgk" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/teambition.png" width="20"> | [AuthTeambitionRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java) | <a href="https://docs.teambition.com/" target="_blank">参考文档</a> |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven%20Central--1.15.4-alpha-blue" ></img>
<img src="https://img.shields.io/badge/Maven%20Central--1.15.5-alpha-blue" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
Expand All @@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api%20Docs--1.15.4-alpha-latest-orange" ></img>
<img src="https://img.shields.io/badge/Api%20Docs--1.15.5-alpha-latest-orange" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
Expand Down Expand Up @@ -96,7 +96,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.15.4-alpha</version>
<version>1.15.5-alpha</version>
</dependency>
```
- 调用api
Expand Down
2 changes: 1 addition & 1 deletion bin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.4-alpha
1.15.5-alpha
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven%20Central--1.15.4-alpha-blue" ></img>
<img src="https://img.shields.io/badge/Maven%20Central--1.15.5-alpha-blue" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
Expand All @@ -18,7 +18,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api%20Docs--1.15.4-alpha-latest-orange" ></img>
<img src="https://img.shields.io/badge/Api%20Docs--1.15.5-alpha-latest-orange" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

![](_media/justauth@0,25x.png)
# JustAuth <small>1.15.4-alpha</small>
# JustAuth <small>1.15.5-alpha</small>

<strong>史上最全的整合第三方登录的开源库</strong>

Expand Down
Binary file added docs/_media/oauth/2f1b9c2c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_media/oauth/7fded4b4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_media/oauth/ac549f1a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_media/oauth/ca78b40f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
- [√ 支付宝登录](oauth/alipay.md)
- [√ 酷家乐登录](oauth/kujiale.md)
- [√ 推特登录](oauth/twitter.md)
- [√ Coding登录](oauth/coding.md)
- [CSDN登录](oauth/csdn.md)
- [微信企业版登录](oauth/wechatEnterprise.md)
- [微信公众平台登录](oauth/wechat_mp.md)
- [百度登录](oauth/baidu.md)
- [Coding登录](oauth/coding.md)
- [钉钉登录](oauth/dingtalk.md)
- [开源中国登录](oauth/oschina.md)
- [淘宝登录](oauth/taobao.md)
- [腾讯云登录](oauth/tencentCloud.md)
- [Google登录](oauth/google.md)
- [Facebook登录](oauth/facebook.md)
- [抖音登录](oauth/douyin.md)
Expand Down
8 changes: 8 additions & 0 deletions docs/oauth/alipay.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ c. 回到应用详情页面,点击【接口加签方式】后面的【设置
</dependency>
```

```
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>3.7.4.ALL</version>
</dependency>
```

`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。

### 2.2 创建Request
Expand Down
151 changes: 151 additions & 0 deletions docs/oauth/coding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
## 1. 申请应用

## 创建 CODING 应用
1. 点击【个人设置】->【开放生态】->【创建应用】,注册需要接入 CODING 的应用。

![](../_media/oauth/7fded4b4.png)

2. 在创建应用页面,填写接入的应用信息:

- 应用名称、应用主页及回调地址为必填项;
- 其中回调地址是用户授权后,CODING 回调到应用,并且回传授权码的地址;
- 如果没有上传图标将自动生成应用图标。

填写完毕后,点击【创建应用】。

![](../_media/oauth/ca78b40f.png)

注意:回调地址不支持 `127.0.0.1``localhost` 等配置

3. 应用创建完成后,在应用详情页,会生成 Client ID 和 Client Secret ,保存以便后续认证使用。

![](../_media/oauth/ac549f1a.png)

## 2. 集成JustAuth

### 2.1 引入依赖

```xml
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>${latest.version}</version>
</dependency>
```

`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。

### 2.2 创建Request

```java
AuthRequest authRequest = new AuthTencentCloudRequest(AuthConfig.builder()
.clientId("App Key")
.clientSecret("App Secret")
.redirectUri("授权回调页")
.build());
```

### 2.3 生成授权地址

我们可以直接使用以下方式生成第三方平台的授权链接:
```java
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
```
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。


### 2.4 以上完整代码如下

```java
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthWeiboRequest;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@RestController
@RequestMapping("/oauth")
public class RestAuthController {

@RequestMapping("/render")
public void renderAuth(HttpServletResponse response) throws IOException {
AuthRequest authRequest = getAuthRequest();
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
}

@RequestMapping("/callback")
public Object login(AuthCallback callback) {
AuthRequest authRequest = getAuthRequest();
return authRequest.login(callback);
}

@RequestMapping("/revoke/{token}")
public Object revokeAuth(@PathVariable("token") String token) throws IOException {
AuthRequest authRequest = getAuthRequest();
return authRequest.revoke(AuthToken.builder().accessToken(token).build());
}

private AuthRequest getAuthRequest() {
return new AuthTencentCloudRequest(AuthConfig.builder()
.clientId("App Key")
.clientSecret("App Secret")
.redirectUri("授权回调页")
// 比如以“ https://justauth.coding.net/ ”为例,codingGroupName = justauth
.codingGroupName("团队名")
.build());
}
}
```
授权链接访问成功后会看到以下页面内容:

![](../_media/oauth/2f1b9c2c.png)

## 3. 授权结果

```json
{
"code": 2000,
"msg": null,
"data": {
"uuid": "xxx",
"username": "yadong.zhang",
"nickname": "yadong.zhang",
"avatar": "https://coding.net/static/fruit_avatar/Fruit-6.png",
"blog": "https://coding.net/u/HNMxPTOFRd",
"company": "",
"location": "",
"email": null,
"remark": "",
"gender": "FEMALE",
"source": "CODING",
"token": {
"accessToken": "xx",
"expireIn": 858292,
"refreshToken": "xx",
"uid": null,
"openId": null,
"accessCode": null,
"unionId": null,
"scope": null,
"tokenType": null,
"idToken": null,
"macAlgorithm": null,
"macKey": null,
"code": null,
"oauthToken": null,
"oauthTokenSecret": null,
"userId": null,
"screenName": null,
"oauthCallbackConfirmed": null
}
}
}
```
28 changes: 28 additions & 0 deletions docs/update.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## 1.15.5-alpha
### 2020/06/07
- 修复
- 解决 `Microsoft` 授权失败的 BUG
- 解决 `Coding` 个人账号授权失败的 BUG(目前只能使用团队模式进行授权,需要传入团队名,参考`AuthConfig#codingGroupName`
- 新增
- 支持 Http 级的代理配置,使用方式:
```java
new AuthGoogleRequest(AuthConfig.builder()
.clientId("")
.clientSecret("")
.redirectUri("http://127.0.0.1:8443/oauth/callback/google")
// 针对国外平台配置代理
.httpConfig(HttpConfig.builder()
.timeout(15000)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build())
.build());
```
- 删除
- 删除**腾讯云登录**。coding 已并入 腾讯云,因此只保留 coding 登录
- 文档
- 新增 [Coding登录](oauth/coding.md)文档
- 完善 [支付宝登录](oauth/alipay.md)文档
- PR
- 合并 [Gitee!17](https://gitee.com/yadong.zhang/JustAuth/pulls/17)
- 合并 [Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)

## 1.15.4-alpha
### 2020/05/13
- 修复
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.15.4-alpha</version>
<version>1.15.5-alpha</version>

<name>JustAuth</name>
<url>https://gitee.com/yadong.zhang/JustAuth</url>
Expand Down Expand Up @@ -60,7 +60,7 @@
<maven-surefire-version>2.20</maven-surefire-version>
<maven-gpg-version>1.6</maven-gpg-version>
<maven.test.skip>false</maven.test.skip>
<simple-http.version>1.0.1</simple-http.version>
<simple-http.version>1.0.2-SNAPSHOT</simple-http.version>
<lombok-version>1.18.10</lombok-version>
<junit-version>4.11</junit-version>
<fastjson-version>1.2.69</fastjson-version>
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/me/zhyd/oauth/config/AuthConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.zhyd.oauth.config;

import com.xkcoding.http.config.HttpConfig;
import lombok.*;

/**
Expand Down Expand Up @@ -59,4 +60,23 @@ public class AuthConfig {
* @since 1.10.0
*/
private String agentId;

/**
* 使用 Coding 登录时,需要传该值。
*
* 团队域名前缀,比如以“ https://justauth.coding.net/ ”为例,{@code codingGroupName} = justauth
*
* @since 1.15.5
*/
private String codingGroupName;

/**
* 针对国外服务可以单独设置代理
* HttpConfig config = new HttpConfig();
* config.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)));
* config.setTimeout(15000);
*
* @since 1.15.5
*/
private HttpConfig httpConfig;
}
Loading

0 comments on commit e93ad07

Please sign in to comment.