From 1740cb6b6d3bf14d9dd64a943464566285c12c6f Mon Sep 17 00:00:00 2001
From: monkeyk7
-Java Config版本请访问Branch: config
+Spring-Boot版本请访问Branch: config
-MongoDB版本请访问Branch: mongodb
+MongoDB版本请访问Branch: mongodb
OAuth2下一代身份认证授权协议OIDC实现: MyOIDC
- OAuth2客户端项目请访问 spring-oauth-client
+ OAuth2客户端项目请访问 spring-oauth-client
在线测试访问地址 http://andaily.com/spring-oauth-server/
- Shiro与OLTU整合的OAuth2项目 http://git.oschina.net/mkk/oauth2-shiro
+ Shiro与OLTU整合的OAuth2项目 https://gitee.com/mkk/oauth2-shiro
(相比spring-oauth-server, 该项目入门门槛相对较低, 代码更加透明, 理解更容易,可扩展性更强, 且模块化开发)
@@ -44,7 +44,7 @@
项目是Maven管理的, 需要本地安装maven(开发用的maven版本号为3.1.0), 还有MySql(开发用的mysql版本号为5.6)
- 如果在使用过程中遇到特殊的问题(如:如何将oauth_code存入数据库),请访问项目的 Wiki
- 与 附件.
+ 如果在使用过程中遇到特殊的问题(如:如何将oauth_code存入数据库),请访问项目的 Wiki
+ 与 附件.
我会把大家反馈的问题解决办法添加在这里.
@@ -105,7 +105,7 @@
- 如果在使用项目的过程中发现任何的BUG或者更好的提议, 建议将其提交到项目的 Issues 中, + 如果在使用项目的过程中发现任何的BUG或者更好的提议, 建议将其提交到项目的 Issues 中, 我会一直关注并不断改进项目.
oauth_code存入数据库的配置
, 请下载文件 oauth_code存入数据库的配置.jpg
+ oauth_code存入数据库的配置
, 请下载文件 oauth_code存入数据库的配置.jpg
改变token过期的时间的配置
, 请下载文件改变token过期的时间的配置.jpg
+ 改变token过期的时间的配置
, 请下载文件改变token过期的时间的配置.jpg
自定义 grant_type
, 默认情况支持的grant_type包括 [password,authorization_code,refresh_token,implicit], 若不需要其中的某些grant_type,
@@ -152,7 +152,7 @@
从 0.3版本开始将项目的所有计划的开发内容列出来, 方便大家跟进, 也欢迎你加入.
-项目的开发管理使用开源项目 andaily-developer.
+项目的开发管理使用开源项目 andaily-developer.
#73 - Upgrade 'spring-security-oauth2' version to '2.0.6.RELEASE' (current: 1.0.5.RELEASE) [CANCELED]
#74 - oauth mysql ddl add create_time, default is now()
2013-11-19 Initial project, start push code 2013-11-20 发布0.1版本 2013-11-20 发布0.1版本 2015-05-06 发布0.2版本 2015-05-27 创建项目博客,访问地址 http://andaily.com/blog/?cat=19 2015-06-07 发布0.3版本 2015-06-07 发布0.3版本
2015-06-16 添加github访问: https://github.com/monkeyk/spring-oauth-server,
以后的更新将同步github与gitosc.
2015-11-09 开始开发 0.4-beta 版本 2015-11-18 发布 0.4-beta 版本 2016-01-02 发布 0.4 版本 2015-11-18 发布 0.4-beta 版本 2016-01-02 发布 0.4 版本 2016-02-19 Add 0.5 version development planning 2016-04-03 Add config branch 2016-04-14 Add mongodb branch 2016-06-02 发布 0.5 版本 2016-04-03 Add config branch 2016-04-14 Add mongodb branch 2016-06-02 发布 0.5 版本 2016-07-06 Add 0.6 version planning 2016-10-13 发布0.6版本 2016-06-02 发布 0.5 版本 2016-07-06 Add 0.6 version planning 2016-10-13 发布0.6版本 2018-04-21 发布2.0.0版本, spring-boot版本#75 - Add user information API, for spring-oauth-client
project use
+ #75 - Add user information API, for spring-oauth-client
project use
URL: /unity/user_info
Login: Yes (ROLE_UNITY)
@@ -266,21 +266,21 @@
--
Gitee
From ae29d52feb53cf61a7b145cab03827ea2fcff2f4 Mon Sep 17 00:00:00 2001
From: monkeyk7
2016-06-02 发布 0.5 版本
2016-07-06 Add 0.6 version planning
2016-10-13 发布0.6版本
2018-04-21 发布2.0.0版本, spring-boot版本
2018-04-21 发布2.0.0版本, spring-boot版本
- Version: 1.0 [pending]
+ Version: 2.0 [pending]
- Date: 2017-03-30 / ---
+ Date: 2018-04-09 / 2018-04-21
+
更新UI,为了更易理解与使用,场景化
增加删除access_token API
增加删除 refresh_token API
---
+ Version: 1.0 [finished]
+
+ Date: 2017-03-30 / 2018-04-04
implicit测试时 取消掉 client secret
更新UI,为了更易理解与使用,场景化
增加删除access_token API
增加删除 refresh_token API
---
更新UI,为了更易理解与使用,场景化
---
+ GitHub项目地址: https://github.com/monkeyk/spring-oauth-server.git +
- Version: 2.0 [pending]
+ Version: 2.0.1 [pending]
+
+ Date: 2018-05-01 / ---
+
增加 /oauth/check_token 可使用 #IJO9H
Fix issue #IJO9R
+ Version: 2.0.0 [finished]
Date: 2018-04-09 / 2018-04-21
更新UI,为了更易理解与使用,场景化
---
增加 /oauth/check_token 可使用 #IJO9H
Fix issue #IJO9R
Fix issue #IJO9R /oauth/rest_token 接口 client_secret字段没有校验
南京索特科技 -- 200元 (2016-12-16)
周广文 -- 6.66元 (2017-02-17)
境随心转 -- 20元 (2017-06-09)
Xyz(秦) -- 50元 (2018-06-05)
增加 /oauth/check_token 可使用 #IJO9H
Fix issue #IJO9R /oauth/rest_token 接口 client_secret字段没有校验
升级spring-boot 版本为 2.0.2.RELEASE
将项目用视频方式展现出来,更直观
增加 /oauth/check_token 可使用 #IJO9H
Fix issue #IJO9R /oauth/rest_token 接口 client_secret字段没有校验
升级spring-boot 版本为 2.0.2.RELEASE
将项目用视频方式展现出来,更直观
+ * Cache 操作相关
+ *
+ * @author Shengzhao Li
+ * @since 1.0
+ */
+public class SOSCacheUtils implements CacheConstants {
+
+
+ private SOSCacheUtils() {
+ }
+
+
+ /**
+ * 用户 Cache
+ *
+ * @return Cache instance
+ */
+ public static Cache userCache() {
+ final CacheManager cacheManager = getCacheManager();
+ return cacheManager.getCache(USER_CACHE);
+ }
+
+ private static CacheManager getCacheManager() {
+ final CacheManager cacheManager = BeanProvider.getBean(CacheManager.class);
+ Assert.notNull(cacheManager, "cacheManager is null");
+ return cacheManager;
+ }
+
+
+}
diff --git a/src/main/java/com/monkeyk/sos/service/business/CurrentUserJsonDtoLoader.java b/src/main/java/com/monkeyk/sos/service/business/CurrentUserJsonDtoLoader.java
new file mode 100644
index 0000000..d7c6706
--- /dev/null
+++ b/src/main/java/com/monkeyk/sos/service/business/CurrentUserJsonDtoLoader.java
@@ -0,0 +1,40 @@
+package com.monkeyk.sos.service.business;
+
+import com.monkeyk.sos.domain.dto.UserJsonDto;
+import com.monkeyk.sos.domain.shared.security.WdcyUserDetails;
+import com.monkeyk.sos.domain.user.UserRepository;
+import com.monkeyk.sos.web.context.BeanProvider;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+
+/**
+ * 2018/10/14
+ *
+ * @author Shengzhao Li
+ * @since 1.0
+ */
+public class CurrentUserJsonDtoLoader {
+
+
+ private transient UserRepository userRepository = BeanProvider.getBean(UserRepository.class);
+
+ public CurrentUserJsonDtoLoader() {
+ }
+
+ public UserJsonDto load() {
+
+ final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ final Object principal = authentication.getPrincipal();
+
+ if (authentication instanceof OAuth2Authentication &&
+ (principal instanceof String || principal instanceof org.springframework.security.core.userdetails.User)) {
+ OauthUserJsonDtoLoader jsonDtoLoader = new OauthUserJsonDtoLoader((OAuth2Authentication) authentication);
+ return jsonDtoLoader.load();
+ } else {
+ final WdcyUserDetails userDetails = (WdcyUserDetails) principal;
+ return new UserJsonDto(userRepository.findByGuid(userDetails.user().guid()));
+ }
+ }
+
+}
diff --git a/src/main/java/com/monkeyk/sos/service/business/OauthUserJsonDtoLoader.java b/src/main/java/com/monkeyk/sos/service/business/OauthUserJsonDtoLoader.java
new file mode 100644
index 0000000..8acf119
--- /dev/null
+++ b/src/main/java/com/monkeyk/sos/service/business/OauthUserJsonDtoLoader.java
@@ -0,0 +1,35 @@
+package com.monkeyk.sos.service.business;
+
+import com.monkeyk.sos.domain.dto.UserJsonDto;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+
+import java.util.Collection;
+
+/**
+ * 2018/10/14
+ *
+ * @author Shengzhao Li
+ * @since 1.0
+ */
+public class OauthUserJsonDtoLoader {
+
+ private OAuth2Authentication oAuth2Authentication;
+
+ public OauthUserJsonDtoLoader(OAuth2Authentication oAuth2Authentication) {
+ this.oAuth2Authentication = oAuth2Authentication;
+ }
+
+ public UserJsonDto load() {
+
+ UserJsonDto userJsonDto = new UserJsonDto();
+ userJsonDto.setUsername(oAuth2Authentication.getName());
+
+ final Collection
+ * Spring bean容器, 启动时初始化
+ *
+ * @author Shengzhao Li
+ * @see SOSContextLoaderListener
+ * @since 1.0
+ */
+public abstract class BeanProvider {
+
+ private static ApplicationContext springApplicationContext;
+
+
+ //private
+ private BeanProvider() {
+ }
+
+ static void initialize(ApplicationContext applicationContext) {
+ BeanProvider.springApplicationContext = applicationContext;
+ }
+
+ public static
+ *
+ * 扩展 Spring Context, 方便获取 bean
+ *
+ * @author Shengzhao Li
+ * @since 1.0
+ */
+public class SOSContextLoaderListener extends ContextLoaderListener {
+
+
+ @Override
+ public void contextInitialized(ServletContextEvent event) {
+ super.contextInitialized(event);
+ //ext
+ WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
+ BeanProvider.initialize(applicationContext);
+ }
+}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 220efb5..81351d7 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -132,11 +132,11 @@
+ Logout
+ 将项目用视频方式展现出来,更直观.
+ *