Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XKZJ_WCL
JustAuth
提交
a08e16e1
J
JustAuth
项目概览
XKZJ_WCL
/
JustAuth
与 Fork 源项目一致
Fork自
justauth / JustAuth
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JustAuth
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a08e16e1
编写于
2月 18, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎉
修改认证方式为显式的传参
上级
8d77311a
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
295 addition
and
169 deletion
+295
-169
pom.xml
pom.xml
+177
-111
src/main/java/me/zhyd/oauth/config/AuthConfig.java
src/main/java/me/zhyd/oauth/config/AuthConfig.java
+9
-34
src/main/java/me/zhyd/oauth/config/GiteeConfig.java
src/main/java/me/zhyd/oauth/config/GiteeConfig.java
+16
-0
src/main/java/me/zhyd/oauth/config/GithubConfig.java
src/main/java/me/zhyd/oauth/config/GithubConfig.java
+16
-0
src/main/java/me/zhyd/oauth/config/QqConfig.java
src/main/java/me/zhyd/oauth/config/QqConfig.java
+17
-0
src/main/java/me/zhyd/oauth/config/WechatConfig.java
src/main/java/me/zhyd/oauth/config/WechatConfig.java
+17
-0
src/main/java/me/zhyd/oauth/config/WeiboConfig.java
src/main/java/me/zhyd/oauth/config/WeiboConfig.java
+16
-0
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
+6
-6
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+6
-6
src/main/java/me/zhyd/oauth/request/AuthRequest.java
src/main/java/me/zhyd/oauth/request/AuthRequest.java
+9
-4
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+6
-7
src/main/java/me/zhyd/oauth/utils/IpUtils.java
src/main/java/me/zhyd/oauth/utils/IpUtils.java
+0
-1
未找到文件。
pom.xml
浏览文件 @
a08e16e1
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<name>
JustAuth
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
<description>
史上最全的整合第三方登录的工具, Just Auth
</description>
<licenses>
<license>
<name>
The Apache Software License, Version 2.0
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE
</url>
</license>
</licenses>
<developers>
<developer>
<name>
yadong.zhang
</name>
<email>
yadong.zhang0415@gmail.com
</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java.version>
1.8
</java.version>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<maven-source.version>
2.2.1
</maven-source.version>
<maven-compiler.version>
3.7.0
</maven-compiler.version>
<maven.test.skip>
true
</maven.test.skip>
<hutool-version>
4.1.21
</hutool-version>
<lombok-version>
1.18.4
</lombok-version>
<junit-version>
4.11
</junit-version>
<servlet-api-version>
2.5
</servlet-api-version>
<fastjson-version>
1.2.44
</fastjson-version>
</properties>
<dependencies>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
${lombok-version}
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-http
</artifactId>
<version>
${hutool-version}
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
${junit-version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<version>
${servlet-api-version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
${fastjson-version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}-${project.version}
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${maven-compiler.version}
</version>
<configuration>
<encoding>
${project.build.sourceEncoding}
</encoding>
<source>
${java.version}
</source>
<target>
${java.version}
</target>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-source-plugin
</artifactId>
<version>
${maven-source.version}
</version>
<inherited>
true
</inherited>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
jar-no-fork
</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-javadoc-plugin
</artifactId>
</plugin>
<!-- GPG -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-gpg-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<name>
JustAuth
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
<description>
史上最全的整合第三方登录的工具, Just Auth
</description>
<licenses>
<license>
<name>
The Apache Software License, Version 2.0
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE
</url>
</license>
</licenses>
<scm>
<connection>
scm:git:https://gitee.com/yadong.zhang/JustAuth.git
</connection>
<developerConnection>
scm:git:https://gitee.com/yadong.zhang/JustAuth.git
</developerConnection>
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
</scm>
<developers>
<developer>
<name>
yadong.zhang
</name>
<email>
yadong.zhang0415@gmail.com
</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java.version>
1.8
</java.version>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<maven-source.version>
2.2.1
</maven-source.version>
<maven-compiler.version>
3.7.0
</maven-compiler.version>
<maven.test.skip>
true
</maven.test.skip>
<hutool-version>
4.1.21
</hutool-version>
<lombok-version>
1.18.4
</lombok-version>
<junit-version>
4.11
</junit-version>
<servlet-api-version>
2.5
</servlet-api-version>
<fastjson-version>
1.2.44
</fastjson-version>
</properties>
<dependencies>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
${lombok-version}
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-http
</artifactId>
<version>
${hutool-version}
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
${junit-version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<version>
${servlet-api-version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
${fastjson-version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}-${project.version}
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${maven-compiler.version}
</version>
<configuration>
<encoding>
${project.build.sourceEncoding}
</encoding>
<source>
${java.version}
</source>
<target>
${java.version}
</target>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-source-plugin
</artifactId>
<version>
${maven-source.version}
</version>
<inherited>
true
</inherited>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
jar-no-fork
</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-javadoc-plugin
</artifactId>
</plugin>
<!-- GPG -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-gpg-plugin
</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>
release
</id>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-source-plugin
</artifactId>
<version>
${maven-source.version}
</version>
<inherited>
true
</inherited>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
jar-no-fork
</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-javadoc-plugin
</artifactId>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
jar
</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-gpg-plugin
</artifactId>
<executions>
<execution>
<phase>
verify
</phase>
<goals>
<goal>
sign
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>
sonatype-oss
</id>
<url>
https://oss.sonatype.org/content/repositories/snapshots/
</url>
</snapshotRepository>
<repository>
<id>
sonatype-oss
</id>
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2/
</url>
</repository>
</distributionManagement>
</profile>
</profiles>
</project>
src/main/java/me/zhyd/oauth/config/AuthConfig.java
浏览文件 @
a08e16e1
package
me.zhyd.oauth.config
;
import
lombok.Builder
;
import
lombok.Getter
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
...
...
@@ -7,41 +10,13 @@ package me.zhyd.oauth.config;
* @date 2019/1/31 14:03
* @since 1.8
*/
@Getter
@Builder
public
class
AuthConfig
{
private
String
clientId
;
private
String
clientSecret
;
/**
* github应用的Client ID
*/
public
static
String
githubClientId
=
null
;
/**
* github应用的Client Secret
*/
public
static
String
githubClientSecret
=
null
;
/**
* github应用的redirect_uri 登陆成功后的回调地址
*/
public
static
String
githubRedirectUri
=
null
;
/**
* weibo应用的App Key
*/
public
static
String
weiboClientId
=
null
;
/**
* weibo应用的App Secret
*/
public
static
String
weiboClientSecret
=
null
;
/**
* weibo应用的redirect_uri 登陆成功后的回调地址
*/
public
static
String
weiboRedirectUri
=
null
;
/**
* gitee应用的Client ID
*/
public
static
String
giteeClientId
=
null
;
/**
* gitee应用的Client Secret
*/
public
static
String
giteeClientSecret
=
null
;
/**
* gitee应用的redirect_uri 登陆成功后的回调地址
* 登陆成功后的回调地址
*/
p
ublic
static
String
giteeRedirectUri
=
null
;
p
rivate
String
redirectUri
;
}
src/main/java/me/zhyd/oauth/config/GiteeConfig.java
0 → 100644
浏览文件 @
a08e16e1
package
me.zhyd.oauth.config
;
import
lombok.Builder
;
import
lombok.Getter
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/14 13:34
* @since 1.8
*/
@Getter
@Builder
public
class
GiteeConfig
extends
AuthConfig
{
}
src/main/java/me/zhyd/oauth/config/GithubConfig.java
0 → 100644
浏览文件 @
a08e16e1
package
me.zhyd.oauth.config
;
import
lombok.Builder
;
import
lombok.Getter
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/14 13:34
* @since 1.8
*/
@Getter
@Builder
public
class
GithubConfig
extends
AuthConfig
{
}
src/main/java/me/zhyd/oauth/config/QqConfig.java
0 → 100644
浏览文件 @
a08e16e1
package
me.zhyd.oauth.config
;
import
lombok.Builder
;
import
lombok.Getter
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/14 13:34
* @since 1.8
*/
@Getter
@Builder
@Deprecated
public
class
QqConfig
extends
AuthConfig
{
}
src/main/java/me/zhyd/oauth/config/WechatConfig.java
0 → 100644
浏览文件 @
a08e16e1
package
me.zhyd.oauth.config
;
import
lombok.Builder
;
import
lombok.Getter
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/14 13:34
* @since 1.8
*/
@Getter
@Builder
@Deprecated
public
class
WechatConfig
extends
AuthConfig
{
}
src/main/java/me/zhyd/oauth/config/WeiboConfig.java
0 → 100644
浏览文件 @
a08e16e1
package
me.zhyd.oauth.config
;
import
lombok.Builder
;
import
lombok.Getter
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/14 13:34
* @since 1.8
*/
@Getter
@Builder
public
class
WeiboConfig
extends
AuthConfig
{
}
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
浏览文件 @
a08e16e1
...
...
@@ -24,11 +24,11 @@ import java.io.IOException;
public
class
AuthGiteeRequest
implements
AuthRequest
{
@Override
public
void
authorize
(
HttpServletResponse
response
)
{
public
void
authorize
(
AuthConfig
config
,
HttpServletResponse
response
)
{
if
(!
AuthConfigChecker
.
isSupportedGitee
())
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
String
authorizeUrl
=
UrlBuilder
.
getGiteeAuthorizeUrl
(
AuthConfig
.
giteeClientId
,
AuthConfig
.
giteeRedirectUri
);
String
authorizeUrl
=
UrlBuilder
.
getGiteeAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
()
);
try
{
response
.
sendRedirect
(
authorizeUrl
);
}
catch
(
IOException
e
)
{
...
...
@@ -37,22 +37,22 @@ public class AuthGiteeRequest implements AuthRequest {
}
@Override
public
String
authorize
()
{
public
String
authorize
(
AuthConfig
config
)
{
if
(!
AuthConfigChecker
.
isSupportedGitee
())
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
return
UrlBuilder
.
getGiteeAuthorizeUrl
(
AuthConfig
.
giteeClientId
,
AuthConfig
.
giteeRedirectUri
);
return
UrlBuilder
.
getGiteeAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
()
);
}
@Override
public
AuthResponse
login
(
String
code
)
{
public
AuthResponse
login
(
AuthConfig
config
,
String
code
)
{
if
(!
AuthConfigChecker
.
isSupportedGitee
())
{
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
UNSUPPORTED
.
getCode
())
.
msg
(
ResponseStatus
.
UNSUPPORTED
.
getMsg
())
.
build
();
}
String
accessTokenUrl
=
UrlBuilder
.
getGiteeAccessTokenUrl
(
AuthConfig
.
giteeClientId
,
AuthConfig
.
giteeClientSecret
,
code
,
AuthConfig
.
giteeRedirectUri
);
String
accessTokenUrl
=
UrlBuilder
.
getGiteeAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
()
);
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
String
accessTokenStr
=
response
.
body
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
accessTokenStr
);
...
...
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
浏览文件 @
a08e16e1
...
...
@@ -24,11 +24,11 @@ import java.io.IOException;
public
class
AuthGithubRequest
implements
AuthRequest
{
@Override
public
void
authorize
(
HttpServletResponse
response
)
{
public
void
authorize
(
AuthConfig
config
,
HttpServletResponse
response
)
{
if
(!
AuthConfigChecker
.
isSupportedGithub
())
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
String
authorizeUrl
=
UrlBuilder
.
getGithubAuthorizeUrl
(
AuthConfig
.
githubClientId
,
AuthConfig
.
githubRedirectUri
);
String
authorizeUrl
=
UrlBuilder
.
getGithubAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
()
);
try
{
response
.
sendRedirect
(
authorizeUrl
);
}
catch
(
IOException
e
)
{
...
...
@@ -37,22 +37,22 @@ public class AuthGithubRequest implements AuthRequest {
}
@Override
public
String
authorize
()
{
public
String
authorize
(
AuthConfig
config
)
{
if
(!
AuthConfigChecker
.
isSupportedGithub
())
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
return
UrlBuilder
.
getGithubAuthorizeUrl
(
AuthConfig
.
githubClientId
,
AuthConfig
.
githubRedirectUri
);
return
UrlBuilder
.
getGithubAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
()
);
}
@Override
public
AuthResponse
login
(
String
code
)
{
public
AuthResponse
login
(
AuthConfig
config
,
String
code
)
{
if
(!
AuthConfigChecker
.
isSupportedGithub
())
{
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
UNSUPPORTED
.
getCode
())
.
msg
(
ResponseStatus
.
UNSUPPORTED
.
getMsg
())
.
build
();
}
String
accessTokenUrl
=
UrlBuilder
.
getGithubAccessTokenUrl
(
AuthConfig
.
githubClientId
,
AuthConfig
.
githubClientSecret
,
code
,
AuthConfig
.
githubRedirectUri
);
String
accessTokenUrl
=
UrlBuilder
.
getGithubAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
()
);
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
String
accessTokenStr
=
response
.
body
();
String
accessToken
=
accessTokenStr
.
split
(
"&"
)[
0
];
...
...
src/main/java/me/zhyd/oauth/request/AuthRequest.java
浏览文件 @
a08e16e1
package
me.zhyd.oauth.request
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
...
...
@@ -17,26 +18,30 @@ public interface AuthRequest {
/**
* 自动跳转到认证页面
*
* @param config 授权的配置,对应不同平台
* @param response response
*/
default
void
authorize
(
HttpServletResponse
response
)
{
default
void
authorize
(
AuthConfig
config
,
HttpServletResponse
response
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
}
/**
* 返回认证url,可自行跳转页面
*
* @param config 授权的配置,对应不同平台
*/
default
String
authorize
()
{
default
String
authorize
(
AuthConfig
config
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
}
/**
* 第三方登录
*
* @param code 通过authorize换回的code
* @param config 授权的配置,对应不同平台
* @param code 通过authorize换回的code
* @return 返回登陆成功后的用户信息
*/
default
AuthResponse
login
(
String
code
)
{
default
AuthResponse
login
(
AuthConfig
config
,
String
code
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
}
}
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
浏览文件 @
a08e16e1
...
...
@@ -16,7 +16,6 @@ import me.zhyd.oauth.utils.UrlBuilder;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.net.InetAddress
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
...
...
@@ -28,11 +27,11 @@ import java.net.InetAddress;
public
class
AuthWeiboRequest
implements
AuthRequest
{
@Override
public
void
authorize
(
HttpServletResponse
response
)
{
public
void
authorize
(
AuthConfig
config
,
HttpServletResponse
response
)
{
if
(!
AuthConfigChecker
.
isSupportedWeibo
())
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
String
authorizeUrl
=
UrlBuilder
.
getWeiboAuthorizeUrl
(
AuthConfig
.
weiboClientId
,
AuthConfig
.
weiboRedirectUri
);
String
authorizeUrl
=
UrlBuilder
.
getWeiboAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
()
);
try
{
response
.
sendRedirect
(
authorizeUrl
);
}
catch
(
IOException
e
)
{
...
...
@@ -41,22 +40,22 @@ public class AuthWeiboRequest implements AuthRequest {
}
@Override
public
String
authorize
()
{
public
String
authorize
(
AuthConfig
config
)
{
if
(!
AuthConfigChecker
.
isSupportedWeibo
())
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
return
UrlBuilder
.
getWeiboAuthorizeUrl
(
AuthConfig
.
weiboClientId
,
AuthConfig
.
weiboRedirectUri
);
return
UrlBuilder
.
getWeiboAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
()
);
}
@Override
public
AuthResponse
login
(
String
code
)
{
public
AuthResponse
login
(
AuthConfig
config
,
String
code
)
{
if
(!
AuthConfigChecker
.
isSupportedWeibo
())
{
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
UNSUPPORTED
.
getCode
())
.
msg
(
ResponseStatus
.
UNSUPPORTED
.
getMsg
())
.
build
();
}
String
accessTokenUrl
=
UrlBuilder
.
getWeiboAccessTokenUrl
(
AuthConfig
.
weiboClientId
,
AuthConfig
.
weiboClientSecret
,
code
,
AuthConfig
.
weiboRedirectUri
);
String
accessTokenUrl
=
UrlBuilder
.
getWeiboAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
()
);
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
String
accessTokenStr
=
response
.
body
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
accessTokenStr
);
...
...
src/main/java/me/zhyd/oauth/utils/IpUtils.java
浏览文件 @
a08e16e1
...
...
@@ -15,7 +15,6 @@ import java.net.UnknownHostException;
* @date 2019/1/31 16:31
* @since 1.0
*/
@Slf4j
public
class
IpUtils
{
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录