Browse Source

🎉 2.0.0.RC8

test
smallchill 6 years ago
parent
commit
bcc88eb08d
  1. 8
      blade-auth/pom.xml
  2. 6
      blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java
  3. 1
      blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java
  4. 26
      blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
  5. 4
      blade-auth/src/main/resources/application-dev.yml
  6. 4
      blade-auth/src/main/resources/application-prod.yml
  7. 4
      blade-auth/src/main/resources/application-test.yml
  8. 2
      blade-auth/src/main/resources/bootstrap.yml
  9. 2
      blade-common/pom.xml
  10. 2
      blade-gateway/pom.xml
  11. 2
      blade-ops/blade-admin/pom.xml
  12. 2
      blade-ops/blade-develop/pom.xml
  13. 2
      blade-ops/pom.xml
  14. 2
      blade-service-api/blade-desk-api/pom.xml
  15. 2
      blade-service-api/blade-dict-api/pom.xml
  16. 2
      blade-service-api/blade-system-api/pom.xml
  17. 2
      blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java
  18. 2
      blade-service-api/blade-user-api/pom.xml
  19. 4
      blade-service-api/pom.xml
  20. 2
      blade-service/blade-desk/pom.xml
  21. 2
      blade-service/blade-log/pom.xml
  22. 2
      blade-service/blade-system/pom.xml
  23. 28
      blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java
  24. 9
      blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java
  25. 4
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.java
  26. 16
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.xml
  27. 4
      blade-service/blade-system/src/main/java/org/springblade/system/service/IAuthClientService.java
  28. 8
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/AuthClientServiceImpl.java
  29. 2
      blade-service/blade-user/pom.xml
  30. 4
      blade-service/pom.xml
  31. 13
      doc/nacos/blade.yaml
  32. 6
      pom.xml
  33. 2
      script/docker/.env

8
blade-auth/pom.xml

@ -8,7 +8,7 @@
<parent>
<artifactId>BladeX</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<artifactId>blade-auth</artifactId>
@ -73,6 +73,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<artifactId>tomcat-jdbc</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

6
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];

1
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<String, Object> 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());

26
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() {

4
blade-auth/src/main/resources/application-dev.yml

@ -1,3 +1,7 @@
#服务器端口
server:
port: 8100
#数据源配置
spring:
datasource:

4
blade-auth/src/main/resources/application-prod.yml

@ -1,3 +1,7 @@
#服务器端口
server:
port: 8100
#数据源配置
spring:
datasource:

4
blade-auth/src/main/resources/application-test.yml

@ -1,3 +1,7 @@
#服务器端口
server:
port: 8100
#数据源配置
spring:
datasource:

2
blade-auth/src/main/resources/bootstrap.yml

@ -1,2 +0,0 @@
server:
port: 8100

2
blade-common/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>BladeX</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-gateway/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>BladeX</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-ops/blade-admin/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-ops</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-ops/blade-develop/pom.xml

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-ops</artifactId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-ops/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>BladeX</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-service-api/blade-desk-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-service-api/blade-dict-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-service-api/blade-system-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Client.java → 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;

2
blade-service-api/blade-user-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

4
blade-service-api/pom.xml

@ -5,13 +5,13 @@
<parent>
<artifactId>BladeX</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-service-api</artifactId>
<name>${project.artifactId}</name>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
<packaging>pom</packaging>
<description>BladeX 微服务API集合</description>

2
blade-service/blade-desk/pom.xml

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-service</artifactId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-service/blade-log/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-service/blade-system/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

28
blade-service/blade-system/src/main/java/org/springblade/system/controller/ClientController.java → 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<Client> detail(Client client) {
Client detail = clientService.getOne(Condition.getQueryWrapper(client));
public R<AuthClient> 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<IPage<Client>> list(Client client, Query query) {
IPage<Client> pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(client));
public R<IPage<AuthClient>> list(AuthClient authClient, Query query) {
IPage<AuthClient> 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));
}

9
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")

4
blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.java → 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<Client> {
public interface AuthClientMapper extends BaseMapper<AuthClient> {
}

16
blade-service/blade-system/src/main/java/org/springblade/system/mapper/ClientMapper.xml → blade-service/blade-system/src/main/java/org/springblade/system/mapper/AuthClientMapper.xml

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.system.mapper.ClientMapper">
<mapper namespace="org.springblade.system.mapper.AuthClientMapper">
<!-- 通用查询映射结果 -->
<resultMap id="clientResultMap" type="org.springblade.system.entity.Client">
<resultMap id="clientResultMap" type="org.springblade.system.entity.AuthClient">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
@ -13,9 +13,15 @@
<result column="is_deleted" property="isDeleted"/>
<result column="client_id" property="clientId"/>
<result column="client_secret" property="clientSecret"/>
<result column="client_name" property="clientName"/>
<result column="redirect_uri" property="redirectUri"/>
<result column="remark" property="remark"/>
<result column="resources_ids" property="resourceIds"/>
<result column="scope" property="scope"/>
<result column="authorized_grant_types" property="authorizedGrantTypes"/>
<result column="web_server_redirect_uri" property="webServerRedirectUri"/>
<result column="authorities" property="authorities"/>
<result column="access_token_validity" property="accessTokenValidity"/>
<result column="refresh_token_validity" property="refreshTokenValidity"/>
<result column="additional_information" property="additionalInformation"/>
<result column="autoapprove" property="autoapprove"/>
</resultMap>
</mapper>

4
blade-service/blade-system/src/main/java/org/springblade/system/service/IClientService.java → 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<Client> {
public interface IAuthClientService extends BaseService<AuthClient> {
}

8
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/ClientServiceImpl.java → 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<ClientMapper, Client> implements IClientService {
public class AuthClientServiceImpl extends BaseServiceImpl<AuthClientMapper, AuthClient> implements IAuthClientService {
}

2
blade-service/blade-user/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

4
blade-service/pom.xml

@ -6,14 +6,14 @@
<artifactId>blade-service</artifactId>
<name>${project.artifactId}</name>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
<packaging>pom</packaging>
<description>BladeX 微服务集合</description>
<parent>
<groupId>org.springblade</groupId>
<artifactId>BladeX</artifactId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
</parent>
<modules>

13
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:

6
pom.xml

@ -5,12 +5,12 @@
<groupId>org.springblade</groupId>
<artifactId>BladeX</artifactId>
<version>2.0.0.RC7</version>
<version>2.0.0.RC8</version>
<packaging>pom</packaging>
<properties>
<bladex.tool.version>2.0.0.RC7</bladex.tool.version>
<bladex.project.version>2.0.0.RC7</bladex.project.version>
<bladex.tool.version>2.0.0.RC8</bladex.tool.version>
<bladex.project.version>2.0.0.RC8</bladex.project.version>
<java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>

2
script/docker/.env

@ -1,2 +1,2 @@
REGISTER=192.168.0.157/blade
TAG=2.0.0.RC7
TAG=2.0.0.RC8

Loading…
Cancel
Save