diff --git a/blade-auth/pom.xml b/blade-auth/pom.xml index b6f5552c..a86dbb45 100644 --- a/blade-auth/pom.xml +++ b/blade-auth/pom.xml @@ -8,7 +8,7 @@ BladeX org.springblade - 2.0.0.RC7 + 2.0.0.RC8 blade-auth @@ -73,6 +73,12 @@ org.springframework.boot spring-boot-starter-jdbc + + + tomcat-jdbc + org.apache.tomcat + + org.springframework.boot diff --git a/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java b/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java index 5ab35645..4cc3aef5 100644 --- a/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java +++ b/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java @@ -55,12 +55,8 @@ public class AppLoginInSuccessHandler extends SavedRequestAwareAuthenticationSuc @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { log.info("【AppLoginInSuccessHandler】 onAuthenticationSuccess authentication={}", authentication); - String header = request.getHeader(TokenUtil.HEADER_KEY); - if (header == null || !header.startsWith(TokenUtil.HEADER_PREFIX)) { - throw new UnapprovedClientAuthenticationException("请求头中无client信息"); - } - String[] tokens = TokenUtil.extractAndDecodeHeader(header); + String[] tokens = TokenUtil.extractAndDecodeHeader(); assert tokens.length == 2; String clientId = tokens[0]; String clientSecret = tokens[1]; diff --git a/blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java b/blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java index b2f2b9ad..0c6d14c5 100644 --- a/blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java +++ b/blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java @@ -36,6 +36,7 @@ public class BladeJwtTokenEnhancer implements TokenEnhancer { public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) { BladeUserDetails principal = (BladeUserDetails) authentication.getUserAuthentication().getPrincipal(); Map info = new HashMap<>(16); + info.put(TokenUtil.CLIENT_ID, TokenUtil.getClientIdFromHeader()); info.put(TokenUtil.USER_ID, principal.getUserId()); info.put(TokenUtil.ROLE_ID, principal.getRoleId()); info.put(TokenUtil.TENANT_CODE, principal.getTenantCode()); diff --git a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java index 7c3c79c9..e3677da3 100644 --- a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java +++ b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java @@ -19,7 +19,10 @@ package org.springblade.auth.utils; import lombok.SneakyThrows; import org.springblade.core.launch.constant.TokenConstant; import org.springblade.core.tool.utils.Charsets; +import org.springblade.core.tool.utils.StringPool; +import org.springblade.core.tool.utils.WebUtil; import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException; import java.util.Base64; import java.util.Calendar; @@ -38,6 +41,7 @@ public class TokenUtil { public final static String USER_NAME = TokenConstant.USER_NAME; public final static String ROLE_NAME = TokenConstant.ROLE_NAME; public final static String TENANT_CODE = TokenConstant.TENANT_CODE; + public final static String CLIENT_ID = TokenConstant.CLIENT_ID; public final static String LICENSE = TokenConstant.LICENSE; public final static String LICENSE_NAME = TokenConstant.LICENSE_NAME; @@ -48,13 +52,17 @@ public class TokenUtil { public final static String HEADER_KEY = "Authorization"; public final static String HEADER_PREFIX = "Basic "; public final static String DEFAULT_AVATAR = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"; + /** * 解码 - * - * @param header */ @SneakyThrows - public static String[] extractAndDecodeHeader(String header) { + public static String[] extractAndDecodeHeader() { + String header = WebUtil.getRequest().getHeader(TokenUtil.HEADER_KEY); + if (header == null || !header.startsWith(TokenUtil.HEADER_PREFIX)) { + throw new UnapprovedClientAuthenticationException("请求头中无client信息"); + } + byte[] base64Token = header.substring(6).getBytes(Charsets.UTF_8_NAME); byte[] decoded; @@ -65,7 +73,7 @@ public class TokenUtil { } String token = new String(decoded, Charsets.UTF_8_NAME); - int index = token.indexOf(":"); + int index = token.indexOf(StringPool.COLON); if (index == -1) { throw new BadCredentialsException("Invalid basic authentication token"); } else { @@ -73,6 +81,15 @@ public class TokenUtil { } } + /** + * 获取请求头中的客户端id + */ + public static String getClientIdFromHeader() { + String[] tokens = extractAndDecodeHeader(); + assert tokens.length == 2; + return tokens[0]; + } + /** * 获取token过期时间(次日凌晨3点) * @@ -90,6 +107,7 @@ public class TokenUtil { /** * 获取refreshToken过期时间 + * * @return expire */ public static int getRefreshTokenValiditySeconds() { diff --git a/blade-auth/src/main/resources/application-dev.yml b/blade-auth/src/main/resources/application-dev.yml index 44a58202..edb797bf 100644 --- a/blade-auth/src/main/resources/application-dev.yml +++ b/blade-auth/src/main/resources/application-dev.yml @@ -1,3 +1,7 @@ +#服务器端口 +server: + port: 8100 + #数据源配置 spring: datasource: diff --git a/blade-auth/src/main/resources/application-prod.yml b/blade-auth/src/main/resources/application-prod.yml index d4cf6a14..6baea344 100644 --- a/blade-auth/src/main/resources/application-prod.yml +++ b/blade-auth/src/main/resources/application-prod.yml @@ -1,3 +1,7 @@ +#服务器端口 +server: + port: 8100 + #数据源配置 spring: datasource: diff --git a/blade-auth/src/main/resources/application-test.yml b/blade-auth/src/main/resources/application-test.yml index 279820d1..dfa7af70 100644 --- a/blade-auth/src/main/resources/application-test.yml +++ b/blade-auth/src/main/resources/application-test.yml @@ -1,3 +1,7 @@ +#服务器端口 +server: + port: 8100 + #数据源配置 spring: datasource: diff --git a/blade-auth/src/main/resources/bootstrap.yml b/blade-auth/src/main/resources/bootstrap.yml deleted file mode 100644 index 64cec20c..00000000 --- a/blade-auth/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: 8100 diff --git a/blade-common/pom.xml b/blade-common/pom.xml index c4f88308..4ac17eb5 100644 --- a/blade-common/pom.xml +++ b/blade-common/pom.xml @@ -5,7 +5,7 @@ BladeX org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-gateway/pom.xml b/blade-gateway/pom.xml index b028c433..8677fb82 100644 --- a/blade-gateway/pom.xml +++ b/blade-gateway/pom.xml @@ -5,7 +5,7 @@ BladeX org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-ops/blade-admin/pom.xml b/blade-ops/blade-admin/pom.xml index 4208f896..01e84103 100644 --- a/blade-ops/blade-admin/pom.xml +++ b/blade-ops/blade-admin/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-ops/blade-develop/pom.xml b/blade-ops/blade-develop/pom.xml index 1326a3b3..10bf9320 100644 --- a/blade-ops/blade-develop/pom.xml +++ b/blade-ops/blade-develop/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-ops - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-ops/pom.xml b/blade-ops/pom.xml index adf91ca2..54304bfc 100644 --- a/blade-ops/pom.xml +++ b/blade-ops/pom.xml @@ -5,7 +5,7 @@ BladeX org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service-api/blade-desk-api/pom.xml b/blade-service-api/blade-desk-api/pom.xml index d60969f1..ec9a3ec3 100644 --- a/blade-service-api/blade-desk-api/pom.xml +++ b/blade-service-api/blade-desk-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service-api/blade-dict-api/pom.xml b/blade-service-api/blade-dict-api/pom.xml index cbcc9aeb..0d274f6b 100644 --- a/blade-service-api/blade-dict-api/pom.xml +++ b/blade-service-api/blade-dict-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service-api/blade-system-api/pom.xml b/blade-service-api/blade-system-api/pom.xml index 8ac8dc9e..d0368c53 100644 --- a/blade-service-api/blade-system-api/pom.xml +++ b/blade-service-api/blade-system-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Client.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java similarity index 98% rename from blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Client.java rename to blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java index 739dec91..00be4f45 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Client.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java @@ -33,7 +33,7 @@ import org.springblade.core.mp.base.BaseEntity; @TableName("blade_client") @EqualsAndHashCode(callSuper = true) @ApiModel(value = "Client对象", description = "Client对象") -public class Client extends BaseEntity { +public class AuthClient extends BaseEntity { private static final long serialVersionUID = 1L; diff --git a/blade-service-api/blade-user-api/pom.xml b/blade-service-api/blade-user-api/pom.xml index 8d644805..de91965d 100644 --- a/blade-service-api/blade-user-api/pom.xml +++ b/blade-service-api/blade-user-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml index 08acc72b..75433621 100644 --- a/blade-service-api/pom.xml +++ b/blade-service-api/pom.xml @@ -5,13 +5,13 @@ BladeX org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 blade-service-api ${project.artifactId} - 2.0.0.RC7 + 2.0.0.RC8 pom BladeX 微服务API集合 diff --git a/blade-service/blade-desk/pom.xml b/blade-service/blade-desk/pom.xml index 8b8549ef..1d86d70b 100644 --- a/blade-service/blade-desk/pom.xml +++ b/blade-service/blade-desk/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-service - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service/blade-log/pom.xml b/blade-service/blade-log/pom.xml index 20f889e7..9a72ad72 100644 --- a/blade-service/blade-log/pom.xml +++ b/blade-service/blade-log/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service/blade-system/pom.xml b/blade-service/blade-system/pom.xml index 5f645ff1..e9e536e4 100644 --- a/blade-service/blade-system/pom.xml +++ b/blade-service/blade-system/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/ClientController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java similarity index 74% rename from blade-service/blade-system/src/main/java/org/springblade/system/controller/ClientController.java rename to blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java index b900de57..4a4b14f3 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/ClientController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java @@ -26,8 +26,8 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; -import org.springblade.system.entity.Client; -import org.springblade.system.service.IClientService; +import org.springblade.system.entity.AuthClient; +import org.springblade.system.service.IAuthClientService; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -43,17 +43,17 @@ import javax.validation.Valid; @RequestMapping("/client") @ApiIgnore @Api(value = "应用管理", tags = "接口") -public class ClientController extends BladeController { +public class AuthClientController extends BladeController { - private IClientService clientService; + private IAuthClientService clientService; /** * 详情 */ @GetMapping("/detail") @ApiOperation(value = "详情", notes = "传入client", position = 1) - public R detail(Client client) { - Client detail = clientService.getOne(Condition.getQueryWrapper(client)); + public R detail(AuthClient authClient) { + AuthClient detail = clientService.getOne(Condition.getQueryWrapper(authClient)); return R.data(detail); } @@ -62,8 +62,8 @@ public class ClientController extends BladeController { */ @GetMapping("/list") @ApiOperation(value = "分页", notes = "传入client", position = 2) - public R> list(Client client, Query query) { - IPage pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(client)); + public R> list(AuthClient authClient, Query query) { + IPage pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(authClient)); return R.data(pages); } @@ -72,8 +72,8 @@ public class ClientController extends BladeController { */ @PostMapping("/save") @ApiOperation(value = "新增", notes = "传入client", position = 4) - public R save(@Valid @RequestBody Client client) { - return R.status(clientService.save(client)); + public R save(@Valid @RequestBody AuthClient authClient) { + return R.status(clientService.save(authClient)); } /** @@ -81,8 +81,8 @@ public class ClientController extends BladeController { */ @PostMapping("/update") @ApiOperation(value = "修改", notes = "传入client", position = 5) - public R update(@Valid @RequestBody Client client) { - return R.status(clientService.updateById(client)); + public R update(@Valid @RequestBody AuthClient authClient) { + return R.status(clientService.updateById(authClient)); } /** @@ -90,8 +90,8 @@ public class ClientController extends BladeController { */ @PostMapping("/submit") @ApiOperation(value = "新增或修改", notes = "传入client", position = 6) - public R submit(@Valid @RequestBody Client client) { - return R.status(clientService.saveOrUpdate(client)); + public R submit(@Valid @RequestBody AuthClient authClient) { + return R.status(clientService.saveOrUpdate(authClient)); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java b/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java index 3399be25..270f081d 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java @@ -16,21 +16,16 @@ */ package org.springblade.system.feign; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.AllArgsConstructor; -import org.springblade.core.tool.constant.BladeConstant; -import org.springblade.system.entity.Client; import org.springblade.system.entity.Dept; import org.springblade.system.entity.Role; -import org.springblade.system.service.IClientService; +import org.springblade.system.service.IAuthClientService; import org.springblade.system.service.IDeptService; import org.springblade.system.service.IRoleService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; -import java.util.List; - /** * 系统服务Feign实现类 * @@ -45,7 +40,7 @@ public class SysClient implements ISysClient { IRoleService roleService; - IClientService clientService; + IAuthClientService clientService; @Override @GetMapping(API_PREFIX + "/getDeptName") diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.java similarity index 89% rename from blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.java rename to blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.java index 4bda1af9..73d2d03e 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.java @@ -17,13 +17,13 @@ package org.springblade.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.springblade.system.entity.Client; +import org.springblade.system.entity.AuthClient; /** * Mapper 接口 * * @author Chill */ -public interface ClientMapper extends BaseMapper { +public interface AuthClientMapper extends BaseMapper { } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.xml similarity index 52% rename from blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.xml rename to blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.xml index d741c6f2..bf617a7c 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.xml +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.xml @@ -1,9 +1,9 @@ - + - + @@ -13,9 +13,15 @@ - - - + + + + + + + + + diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IClientService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IAuthClientService.java similarity index 89% rename from blade-service/blade-system/src/main/java/org/springblade/system/service/IClientService.java rename to blade-service/blade-system/src/main/java/org/springblade/system/service/IAuthClientService.java index d340e773..695eb1dc 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IClientService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IAuthClientService.java @@ -17,13 +17,13 @@ package org.springblade.system.service; import org.springblade.core.mp.base.BaseService; -import org.springblade.system.entity.Client; +import org.springblade.system.entity.AuthClient; /** * 服务类 * * @author Chill */ -public interface IClientService extends BaseService { +public interface IAuthClientService extends BaseService { } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/ClientServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/AuthClientServiceImpl.java similarity index 78% rename from blade-service/blade-system/src/main/java/org/springblade/system/service/impl/ClientServiceImpl.java rename to blade-service/blade-system/src/main/java/org/springblade/system/service/impl/AuthClientServiceImpl.java index 14abbe27..a375e482 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/ClientServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/AuthClientServiceImpl.java @@ -17,9 +17,9 @@ package org.springblade.system.service.impl; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.system.entity.Client; -import org.springblade.system.mapper.ClientMapper; -import org.springblade.system.service.IClientService; +import org.springblade.system.entity.AuthClient; +import org.springblade.system.mapper.AuthClientMapper; +import org.springblade.system.service.IAuthClientService; import org.springframework.stereotype.Service; /** @@ -28,6 +28,6 @@ import org.springframework.stereotype.Service; * @author Chill */ @Service -public class ClientServiceImpl extends BaseServiceImpl implements IClientService { +public class AuthClientServiceImpl extends BaseServiceImpl implements IAuthClientService { } diff --git a/blade-service/blade-user/pom.xml b/blade-service/blade-user/pom.xml index 989d2c78..00d3b347 100644 --- a/blade-service/blade-user/pom.xml +++ b/blade-service/blade-user/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.0.0.RC7 + 2.0.0.RC8 4.0.0 diff --git a/blade-service/pom.xml b/blade-service/pom.xml index ac9bec88..20395d02 100644 --- a/blade-service/pom.xml +++ b/blade-service/pom.xml @@ -6,14 +6,14 @@ blade-service ${project.artifactId} - 2.0.0.RC7 + 2.0.0.RC8 pom BladeX 微服务集合 org.springblade BladeX - 2.0.0.RC7 + 2.0.0.RC8 diff --git a/doc/nacos/blade.yaml b/doc/nacos/blade.yaml index 4528d55e..4ca970c8 100644 --- a/doc/nacos/blade.yaml +++ b/doc/nacos/blade.yaml @@ -66,8 +66,19 @@ management: health: show-details: always -# 租户表维护 +#blade配置 blade: + secure: + url: + exclude-patterns: + - /test/** + client: + - client-id: sword + path-patterns: + - /sword/** + - client-id: saber + path-patterns: + - /saber/** tenant: column: tenant_code tables: diff --git a/pom.xml b/pom.xml index 416f695a..512c6d15 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.springblade BladeX - 2.0.0.RC7 + 2.0.0.RC8 pom - 2.0.0.RC7 - 2.0.0.RC7 + 2.0.0.RC8 + 2.0.0.RC8 1.8 2.9.2 diff --git a/script/docker/.env b/script/docker/.env index 2d476d7d..b681c25c 100644 --- a/script/docker/.env +++ b/script/docker/.env @@ -1,2 +1,2 @@ REGISTER=192.168.0.157/blade -TAG=2.0.0.RC7 +TAG=2.0.0.RC8