Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
智布道
OneBlog
提交
6541f854
O
OneBlog
项目概览
智布道
/
OneBlog
9 个月 前同步成功
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneBlog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6541f854
编写于
8月 07, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
⬆
JustAuth升级到1.10.0
上级
6e054bd2
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
460 addition
and
21 deletion
+460
-21
blog-core/src/main/java/com/zyd/blog/business/service/AuthService.java
.../main/java/com/zyd/blog/business/service/AuthService.java
+3
-1
blog-core/src/main/java/com/zyd/blog/business/service/SysUserService.java
...in/java/com/zyd/blog/business/service/SysUserService.java
+0
-1
blog-core/src/main/java/com/zyd/blog/business/service/impl/AuthServiceImpl.java
...a/com/zyd/blog/business/service/impl/AuthServiceImpl.java
+3
-3
blog-core/src/main/java/com/zyd/blog/framework/property/JustAuthProperties.java
...a/com/zyd/blog/framework/property/JustAuthProperties.java
+12
-0
blog-core/src/main/java/com/zyd/blog/framework/tag/CustomTags.java
.../src/main/java/com/zyd/blog/framework/tag/CustomTags.java
+14
-9
blog-core/src/main/java/com/zyd/blog/plugin/oauth/DouyinRequest.java
...rc/main/java/com/zyd/blog/plugin/oauth/DouyinRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/HuaweiRequest.java
...rc/main/java/com/zyd/blog/plugin/oauth/HuaweiRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/LinkedinRequest.java
.../main/java/com/zyd/blog/plugin/oauth/LinkedinRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/MiRequest.java
...re/src/main/java/com/zyd/blog/plugin/oauth/MiRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/MicrosoftRequest.java
...main/java/com/zyd/blog/plugin/oauth/MicrosoftRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/PinterestRequest.java
...main/java/com/zyd/blog/plugin/oauth/PinterestRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/RenrenRequest.java
...rc/main/java/com/zyd/blog/plugin/oauth/RenrenRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/StackoverflowRequest.java
.../java/com/zyd/blog/plugin/oauth/StackoverflowRequest.java
+39
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/TeambitionRequest.java
...ain/java/com/zyd/blog/plugin/oauth/TeambitionRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/ToutiaoRequest.java
...c/main/java/com/zyd/blog/plugin/oauth/ToutiaoRequest.java
+38
-0
blog-core/src/main/java/com/zyd/blog/plugin/oauth/WechatEnterpriseRequest.java
...va/com/zyd/blog/plugin/oauth/WechatEnterpriseRequest.java
+39
-0
blog-web/src/main/java/com/zyd/blog/controller/OAuthController.java
...rc/main/java/com/zyd/blog/controller/OAuthController.java
+7
-6
pom.xml
pom.xml
+1
-1
未找到文件。
blog-core/src/main/java/com/zyd/blog/business/service/AuthService.java
浏览文件 @
6541f854
package
com.zyd.blog.business.service
;
import
me.zhyd.oauth.model.AuthCallback
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
...
...
@@ -9,7 +11,7 @@ package com.zyd.blog.business.service;
*/
public
interface
AuthService
{
boolean
login
(
String
source
,
String
code
,
String
auth_code
);
boolean
login
(
String
source
,
AuthCallback
callback
);
boolean
revoke
(
String
source
,
Long
userId
);
...
...
blog-core/src/main/java/com/zyd/blog/business/service/SysUserService.java
浏览文件 @
6541f854
...
...
@@ -6,7 +6,6 @@ import com.zyd.blog.business.entity.User;
import
com.zyd.blog.business.entity.UserPwd
;
import
com.zyd.blog.business.vo.UserConditionVO
;
import
com.zyd.blog.framework.object.AbstractService
;
import
me.zhyd.oauth.model.AuthSource
;
import
java.util.List
;
...
...
blog-core/src/main/java/com/zyd/blog/business/service/impl/AuthServiceImpl.java
浏览文件 @
6541f854
...
...
@@ -8,12 +8,12 @@ import com.zyd.blog.plugin.oauth.RequestFactory;
import
com.zyd.blog.util.BeanConvertUtil
;
import
com.zyd.blog.util.SessionUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
...
...
@@ -30,9 +30,9 @@ public class AuthServiceImpl implements AuthService {
private
SysUserService
userService
;
@Override
public
boolean
login
(
String
source
,
String
code
,
String
auth_code
)
{
public
boolean
login
(
String
source
,
AuthCallback
callback
)
{
AuthRequest
authRequest
=
RequestFactory
.
getInstance
(
source
).
getRequest
();
AuthResponse
response
=
authRequest
.
login
(
StringUtils
.
isEmpty
(
code
)
?
auth_code
:
code
);
AuthResponse
response
=
authRequest
.
login
(
callback
);
if
(
response
.
ok
())
{
AuthUser
authUser
=
(
AuthUser
)
response
.
getData
();
User
newUser
=
BeanConvertUtil
.
doConvert
(
authUser
,
User
.
class
);
...
...
blog-core/src/main/java/com/zyd/blog/framework/property/JustAuthProperties.java
浏览文件 @
6541f854
...
...
@@ -36,4 +36,16 @@ public class JustAuthProperties {
private
AuthConfig
google
;
private
AuthConfig
facebook
;
private
AuthConfig
csdn
;
private
AuthConfig
douyin
;
private
AuthConfig
linkedin
;
private
AuthConfig
microsoft
;
private
AuthConfig
mi
;
private
AuthConfig
toutiao
;
private
AuthConfig
teambition
;
private
AuthConfig
renren
;
private
AuthConfig
pinterest
;
private
AuthConfig
stackoverflow
;
private
AuthConfig
huawei
;
private
AuthConfig
wechatEnterprise
;
}
blog-core/src/main/java/com/zyd/blog/framework/tag/CustomTags.java
浏览文件 @
6541f854
...
...
@@ -8,7 +8,8 @@ import com.zyd.blog.framework.property.JustAuthProperties;
import
com.zyd.blog.util.SessionUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.AuthConfigChecker
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.utils.AuthChecker
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -133,16 +134,20 @@ public class CustomTags extends BaseTag {
for
(
Field
f
:
authProperties
.
getClass
().
getDeclaredFields
())
{
f
.
setAccessible
(
true
);
String
fieldName
=
f
.
getName
();
AuthSource
source
=
null
;
if
(
"tencentCloud"
.
equals
(
fieldName
))
{
source
=
AuthSource
.
TENCENT_CLOUD
;
}
else
if
(
"stackoverflow"
.
equals
(
fieldName
))
{
source
=
AuthSource
.
STACK_OVERFLOW
;
}
else
if
(
"wechatEnterprise"
.
equals
(
fieldName
))
{
source
=
AuthSource
.
WECHAT_ENTERPRISE
;
}
else
{
source
=
AuthSource
.
valueOf
(
fieldName
.
toUpperCase
());
}
AuthConfig
authConfig
=
(
AuthConfig
)
f
.
get
(
authProperties
);
if
(
null
!=
authConfig
)
{
if
(
AuthConfigChecker
.
isSupportedAuth
(
authConfig
))
{
if
(
"alipay"
.
equals
(
fieldName
))
{
if
(!
StringUtils
.
isEmpty
(
authConfig
.
getAlipayPublicKey
()))
{
list
.
add
(
fieldName
);
}
}
else
{
list
.
add
(
fieldName
);
}
if
(
AuthChecker
.
isSupportedAuth
(
authConfig
,
source
))
{
list
.
add
(
fieldName
);
}
}
...
...
blog-core/src/main/java/com/zyd/blog/plugin/oauth/DouyinRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthDouyinRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
DouyinRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getDouyin
();
return
new
AuthDouyinRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"douyin"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/HuaweiRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthHuaweiRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
HuaweiRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getHuawei
();
return
new
AuthHuaweiRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"huawei"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/LinkedinRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthLinkedinRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
LinkedinRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getLinkedin
();
return
new
AuthLinkedinRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"linkedin"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/MiRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthMiRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
MiRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getMi
();
return
new
AuthMiRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"mi"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/MicrosoftRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthMicrosoftRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
MicrosoftRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getMicrosoft
();
return
new
AuthMicrosoftRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"microsoft"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/PinterestRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthPinterestRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
PinterestRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getPinterest
();
return
new
AuthPinterestRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"pinterest"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/RenrenRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthRenrenRequest
;
import
me.zhyd.oauth.request.AuthRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
RenrenRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getRenren
();
return
new
AuthRenrenRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"renren"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/StackoverflowRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthRequest
;
import
me.zhyd.oauth.request.AuthStackOverflowRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
StackoverflowRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getStackoverflow
();
return
new
AuthStackOverflowRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
stackOverflowKey
(
authConfig
.
getStackOverflowKey
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"stackoverflow"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/TeambitionRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthRequest
;
import
me.zhyd.oauth.request.AuthTeambitionRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
TeambitionRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getTeambition
();
return
new
AuthTeambitionRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"teambition"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/ToutiaoRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthRequest
;
import
me.zhyd.oauth.request.AuthToutiaoRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
ToutiaoRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getToutiao
();
return
new
AuthToutiaoRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"toutiao"
,
this
);
}
}
blog-core/src/main/java/com/zyd/blog/plugin/oauth/WechatEnterpriseRequest.java
0 → 100644
浏览文件 @
6541f854
package
com.zyd.blog.plugin.oauth
;
import
com.zyd.blog.framework.property.JustAuthProperties
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.request.AuthRequest
;
import
me.zhyd.oauth.request.AuthWeChatEnterpriseRequest
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/8/7 21:37
* @since 1.8
*/
@Component
public
class
WechatEnterpriseRequest
implements
OauthRequest
,
InitializingBean
{
@Autowired
private
JustAuthProperties
properties
;
@Override
public
AuthRequest
getRequest
()
{
AuthConfig
authConfig
=
properties
.
getWechatEnterprise
();
return
new
AuthWeChatEnterpriseRequest
(
AuthConfig
.
builder
()
.
clientId
(
authConfig
.
getClientId
())
.
clientSecret
(
authConfig
.
getClientSecret
())
.
redirectUri
(
authConfig
.
getRedirectUri
())
.
agentId
(
authConfig
.
getAgentId
())
.
build
());
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
RequestFactory
.
registerRequest
(
"wechatEnterprise"
,
this
);
}
}
blog-web/src/main/java/com/zyd/blog/controller/OAuthController.java
浏览文件 @
6541f854
...
...
@@ -4,9 +4,11 @@ import com.zyd.blog.business.service.AuthService;
import
com.zyd.blog.plugin.oauth.RequestFactory
;
import
com.zyd.blog.util.RequestUtil
;
import
com.zyd.blog.util.ResultUtil
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.request.AuthRequest
;
import
me.zhyd.oauth.utils.AuthStateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.StringUtils
;
...
...
@@ -36,20 +38,19 @@ public class OAuthController {
public
void
renderAuth
(
@PathVariable
(
"source"
)
String
source
,
HttpServletResponse
response
,
HttpSession
session
)
throws
IOException
{
AuthRequest
authRequest
=
RequestFactory
.
getInstance
(
source
).
getRequest
();
session
.
setAttribute
(
"historyUrl"
,
RequestUtil
.
getReferer
());
response
.
sendRedirect
(
authRequest
.
authorize
());
response
.
sendRedirect
(
authRequest
.
authorize
(
AuthStateUtils
.
createState
()
));
}
/**
* 授权回调地址
*
* @param source 授权回调来源
* @param code 认证code
* @param auth_code 认证code,当使用支付宝登陆时,该值不为空。切勿修改该参数的命名!强迫症不要把他改成驼峰式命名哈~~~
* @param source 授权回调来源
* @param callback 回调参数包装类
* @return
*/
@RequestMapping
(
"/callback/{source}"
)
public
ModelAndView
login
(
@PathVariable
(
"source"
)
String
source
,
String
code
,
String
auth_code
,
HttpSession
session
)
{
authService
.
login
(
source
,
c
ode
,
auth_code
);
public
ModelAndView
login
(
@PathVariable
(
"source"
)
String
source
,
AuthCallback
callback
,
HttpSession
session
)
{
authService
.
login
(
source
,
c
allback
);
String
historyUrl
=
(
String
)
session
.
getAttribute
(
"historyUrl"
);
session
.
removeAttribute
(
"historyUrl"
);
if
(
StringUtils
.
isEmpty
(
historyUrl
))
{
...
...
pom.xml
浏览文件 @
6541f854
...
...
@@ -51,7 +51,7 @@
<aliyun.oss.version>
2.8.3
</aliyun.oss.version>
<oneblog.version>
2.2.2
</oneblog.version>
<blog-hunter.version>
1.0.1
</blog-hunter.version>
<justauth.version>
1.
5.1
</justauth.version>
<justauth.version>
1.
10.0
</justauth.version>
</properties>
<dependencyManagement>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录