From c63a6f469a5baf3a7b42de5dcfc5977325d47434 Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 19 Aug 2020 23:54:25 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=202.7.2.RELEASE=20=E9=9B=86=E6=88=90Just?= =?UTF-8?q?Auth=E6=94=AF=E6=8C=81=E7=AC=AC=E4=B8=89=E6=96=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- blade-core-boot/pom.xml | 2 +- .../core/boot/logger/RequestLogAspect.java | 15 ++ .../src/main/resources/bootstrap.yml | 2 +- blade-core-cloud/pom.xml | 2 +- blade-core-develop/pom.xml | 2 +- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 2 +- .../core/launch/constant/TokenConstant.java | 1 + blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-secure/pom.xml | 2 +- .../org/springblade/core/secure/AuthInfo.java | 9 ++ blade-core-social/pom.xml | 36 +++++ .../social/config/SocialConfiguration.java | 44 +++++ .../core/social/props/SocialProperties.java | 57 +++++++ .../core/social/utils/SocialUtil.java | 150 ++++++++++++++++++ blade-core-swagger/pom.xml | 2 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- blade-core-transaction/pom.xml | 2 +- pom.xml | 13 +- 24 files changed, 336 insertions(+), 23 deletions(-) create mode 100644 blade-core-social/pom.xml create mode 100644 blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java create mode 100644 blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java create mode 100644 blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java diff --git a/README.md b/README.md index 9fa7466..6c89615 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 1777a56..933f9be 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/logger/RequestLogAspect.java b/blade-core-boot/src/main/java/org/springblade/core/boot/logger/RequestLogAspect.java index 5cc4d8e..c36e446 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/logger/RequestLogAspect.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/logger/RequestLogAspect.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; /** * Spring boot 控制器 请求日志,方便代码调试 @@ -66,6 +67,7 @@ public class RequestLogAspect { continue; } RequestBody requestBody = methodParam.getParameterAnnotation(RequestBody.class); + String parameterName = methodParam.getParameterName(); Object value = args[i]; // 如果是body的json则是对象 if (requestBody != null && value != null) { @@ -89,6 +91,19 @@ public class RequestLogAspect { } else if (value instanceof HttpServletResponse) { } else if (value instanceof InputStream) { } else if (value instanceof InputStreamSource) { + } else if (value instanceof List) { + List list = (List) value; + AtomicBoolean isSkip = new AtomicBoolean(false); + for (Object o : list) { + if ("StandardMultipartFile".equalsIgnoreCase(o.getClass().getSimpleName())) { + isSkip.set(true); + break; + } + } + if (isSkip.get()) { + paraMap.put(parameterName, "此参数不能序列化为json"); + continue; + } } else { // 参数名 RequestParam requestParam = methodParam.getParameterAnnotation(RequestParam.class); diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index 4804c3b..f87e636 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -97,7 +97,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.7.1 + version: 2.7.2 license: Powered By SpringBlade licenseUrl: https://bladex.vip terms-of-service-url: https://bladex.vip diff --git a/blade-core-cloud/pom.xml b/blade-core-cloud/pom.xml index 4848612..5328eb5 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index e9e91f6..10b444a 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index 79fcb40..ab89a71 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java index 69e9ab7..f3f7541 100644 --- a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java +++ b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java @@ -25,7 +25,7 @@ public interface AppConstant { /** * 应用版本 */ - String APPLICATION_VERSION = "2.7.1"; + String APPLICATION_VERSION = "2.7.2"; /** * 基础包 diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java index 94a40e9..9a30741 100644 --- a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java +++ b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java @@ -36,6 +36,7 @@ public interface TokenConstant { String USER_NAME = "user_name"; String ROLE_NAME = "role_name"; String TENANT_ID = "tenant_id"; + String OAUTH_ID = "oauth_id"; String CLIENT_ID = "client_id"; String LICENSE = "license"; String LICENSE_NAME = "powered by blade"; diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index 71da98e..94041af 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index d6e485a..1d2b061 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index 96a3195..cd00546 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 5f4073d..e3db633 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/AuthInfo.java b/blade-core-secure/src/main/java/org/springblade/core/secure/AuthInfo.java index a8028cc..889bf0d 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/AuthInfo.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/AuthInfo.java @@ -15,6 +15,8 @@ */ package org.springblade.core.secure; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -33,6 +35,13 @@ public class AuthInfo { private String tokenType; @ApiModelProperty(value = "刷新令牌") private String refreshToken; + @ApiModelProperty(value = "用户ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long userId; + @ApiModelProperty(value = "租户ID") + private String tenantId; + @ApiModelProperty(value = "第三方系统ID") + private String oauthId; @ApiModelProperty(value = "头像") private String avatar = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"; @ApiModelProperty(value = "角色名") diff --git a/blade-core-social/pom.xml b/blade-core-social/pom.xml new file mode 100644 index 0000000..a1e5953 --- /dev/null +++ b/blade-core-social/pom.xml @@ -0,0 +1,36 @@ + + + + blade-tool + org.springblade + 2.7.2 + + 4.0.0 + + blade-core-social + ${project.artifactId} + ${blade.tool.version} + jar + + + + + org.springblade + blade-core-tool + ${blade.tool.version} + + + + me.zhyd.oauth + JustAuth + 1.15.6 + + + org.apache.httpcomponents + httpclient + + + + diff --git a/blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java b/blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java new file mode 100644 index 0000000..10bd116 --- /dev/null +++ b/blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.social.config; + +import com.xkcoding.http.HttpUtil; +import com.xkcoding.http.support.Http; +import com.xkcoding.http.support.httpclient.HttpClientImpl; +import org.springblade.core.social.props.SocialProperties; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * SocialConfiguration + * + * @author Chill + */ +@Configuration +@EnableConfigurationProperties(SocialProperties.class) +public class SocialConfiguration { + + @Bean + @ConditionalOnMissingBean(Http.class) + public Http simpleHttp() { + HttpClientImpl httpClient = new HttpClientImpl(); + HttpUtil.setHttp(httpClient); + return httpClient; + } + +} diff --git a/blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java b/blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java new file mode 100644 index 0000000..33ce734 --- /dev/null +++ b/blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.social.props; + +import com.google.common.collect.Maps; +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 java.util.Map; + +/** + * SocialProperties + * + * @author Chill + */ +@Getter +@Setter +@ConfigurationProperties(prefix = "social") +public class SocialProperties { + + /** + * 启用 + */ + private Boolean enabled = false; + + /** + * 域名地址 + */ + private String domain; + + /** + * 类型 + */ + private Map oauth = Maps.newHashMap(); + + /** + * 别名 + */ + private Map alias = Maps.newHashMap(); + +} diff --git a/blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java b/blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java new file mode 100644 index 0000000..d3e6140 --- /dev/null +++ b/blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.social.utils; + +import me.zhyd.oauth.config.AuthConfig; +import me.zhyd.oauth.config.AuthDefaultSource; +import me.zhyd.oauth.exception.AuthException; +import me.zhyd.oauth.request.*; +import org.springblade.core.social.props.SocialProperties; + +import java.util.Objects; + +/** + * SocialUtil + * + * @author Chill + */ +public class SocialUtil { + + /** + * 根据具体的授权来源,获取授权请求工具类 + * + * @param source 授权来源 + * @return AuthRequest + */ + public static AuthRequest getAuthRequest(String source, SocialProperties socialProperties) { + AuthDefaultSource authSource = Objects.requireNonNull(AuthDefaultSource.valueOf(source.toUpperCase())); + AuthConfig authConfig = socialProperties.getOauth().get(authSource); + if (authConfig == null) { + throw new AuthException("未获取到有效的Auth配置"); + } + AuthRequest authRequest = null; + switch (authSource) { + case GITHUB: + authRequest = new AuthGithubRequest(authConfig); + break; + case GITEE: + authRequest = new AuthGiteeRequest(authConfig); + break; + case OSCHINA: + authRequest = new AuthOschinaRequest(authConfig); + break; + case QQ: + authRequest = new AuthQqRequest(authConfig); + break; + case WECHAT_OPEN: + authRequest = new AuthWeChatOpenRequest(authConfig); + break; + case WECHAT_ENTERPRISE: + authRequest = new AuthWeChatEnterpriseRequest(authConfig); + break; + case WECHAT_MP: + authRequest = new AuthWeChatMpRequest(authConfig); + break; + case DINGTALK: + authRequest = new AuthDingTalkRequest(authConfig); + break; + case ALIPAY: + // 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip + authRequest = new AuthAlipayRequest(authConfig); + break; + case BAIDU: + authRequest = new AuthBaiduRequest(authConfig); + break; + case WEIBO: + authRequest = new AuthWeiboRequest(authConfig); + break; + case CODING: + authRequest = new AuthCodingRequest(authConfig); + break; + case CSDN: + authRequest = new AuthCsdnRequest(authConfig); + break; + case TAOBAO: + authRequest = new AuthTaobaoRequest(authConfig); + break; + case GOOGLE: + authRequest = new AuthGoogleRequest(authConfig); + break; + case FACEBOOK: + authRequest = new AuthFacebookRequest(authConfig); + break; + case DOUYIN: + authRequest = new AuthDouyinRequest(authConfig); + break; + case LINKEDIN: + authRequest = new AuthLinkedinRequest(authConfig); + break; + case MICROSOFT: + authRequest = new AuthMicrosoftRequest(authConfig); + break; + case MI: + authRequest = new AuthMiRequest(authConfig); + break; + case TOUTIAO: + authRequest = new AuthToutiaoRequest(authConfig); + break; + case TEAMBITION: + authRequest = new AuthTeambitionRequest(authConfig); + break; + case PINTEREST: + authRequest = new AuthPinterestRequest(authConfig); + break; + case RENREN: + authRequest = new AuthRenrenRequest(authConfig); + break; + case STACK_OVERFLOW: + authRequest = new AuthStackOverflowRequest(authConfig); + break; + case HUAWEI: + authRequest = new AuthHuaweiRequest(authConfig); + break; + case KUJIALE: + authRequest = new AuthKujialeRequest(authConfig); + break; + case GITLAB: + authRequest = new AuthGitlabRequest(authConfig); + break; + case MEITUAN: + authRequest = new AuthMeituanRequest(authConfig); + break; + case ELEME: + authRequest = new AuthElemeRequest(authConfig); + break; + case TWITTER: + authRequest = new AuthTwitterRequest(authConfig); + break; + default: + break; + } + if (null == authRequest) { + throw new AuthException("未获取到有效的Auth配置"); + } + return authRequest; + } + +} diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 6b9a346..d7661ad 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java index 0ea633d..c4ccb52 100644 --- a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java +++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java @@ -55,7 +55,7 @@ public class SwaggerProperties { /** * 版本 **/ - private String version = "2.7.1"; + private String version = "2.7.2"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index dbeb991..7c69831 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 8858fc3..97dd0b6 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index 74f1a79..2ccb8cf 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/pom.xml b/pom.xml index 153b653..9145669 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 pom blade-tool @@ -36,23 +36,23 @@ - 2.7.1 + 2.7.2 1.8 3.8.0 2.9.2 1.5.21 - 2.0.3 + 2.0.4 3.3.2 1.6.0 3.4.2 - 2.2.3 + 2.3.0 1.1.0 2.2.1.RELEASE 1.3.0 - 2.2.7.RELEASE - Hoxton.SR5 + 2.2.9.RELEASE + Hoxton.SR7 Cairo-SR8 UTF-8 @@ -67,6 +67,7 @@ blade-core-log blade-core-mybatis blade-core-secure + blade-core-social blade-core-swagger blade-core-test blade-core-tool