Browse Source

内部应用注解认证修改

master
wxz 5 years ago
parent
commit
f63d437461
  1. 9
      epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java
  2. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  3. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/KcScreenController.java
  4. 8
      epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml

9
epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java

@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -82,10 +83,10 @@ public class ExternalAppRequestAuthAspect {
} else if (signature.getMethod().getAnnotation(InternalAppRequestAuth.class) != null } else if (signature.getMethod().getAnnotation(InternalAppRequestAuth.class) != null
&& StringUtils.isNotBlank(request.getHeader(AUTHORIZATION_TOKEN_HEADER_KEY))) { && StringUtils.isNotBlank(request.getHeader(AUTHORIZATION_TOKEN_HEADER_KEY))) {
// 走内部应用认证 // 走内部应用认证
String customerId = null;
internalAppAuth(signature, point, request); internalAppAuth(signature, point, request);
} else { } else {
throw new RenException(EpmetErrorCode.UNSUPPORT_AUTH_TYPE.getCode(), EpmetErrorCode.UNSUPPORT_AUTH_TYPE.getMsg()); logger.error("根据header无法找到适用的认证方式");
throw new RenException(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg());
} }
} }
@ -101,6 +102,10 @@ public class ExternalAppRequestAuthAspect {
BaseTokenDto tokenDTO = getTokenDTO(authorization); BaseTokenDto tokenDTO = getTokenDTO(authorization);
Map<String, Object> tokenMap = redisUtils.hGetAll(RedisKeys.getCpUserKey(tokenDTO.getApp(), tokenDTO.getClient(), tokenDTO.getUserId())); Map<String, Object> tokenMap = redisUtils.hGetAll(RedisKeys.getCpUserKey(tokenDTO.getApp(), tokenDTO.getClient(), tokenDTO.getUserId()));
if (CollectionUtils.isEmpty(tokenMap)) {
logger.error("内部应用认证,redis中没有找到登录缓存信息");
throw new RenException(EpmetErrorCode.ERR10006.getCode(), EpmetErrorCode.ERR10006.getMsg());
}
BaseTokenDto baseTokenDto = null; BaseTokenDto baseTokenDto = null;
String customerId; String customerId;
if ("gov".equals(tokenDTO.getApp())) { if ("gov".equals(tokenDTO.getApp())) {

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -110,7 +110,6 @@ public enum EpmetErrorCode {
OPER_CUSTOMER_FOOTBAR_EXISTS(8712, "footbar已存在"), OPER_CUSTOMER_FOOTBAR_EXISTS(8712, "footbar已存在"),
OPER_CUSTOMER_FOOTBAR_NOT_FOUND(8713, "footbar不存在"), OPER_CUSTOMER_FOOTBAR_NOT_FOUND(8713, "footbar不存在"),
OPER_EXT_APP_SECRET_RESET_FAIL(8714, "秘钥更新失败"), OPER_EXT_APP_SECRET_RESET_FAIL(8714, "秘钥更新失败"),
UNSUPPORT_AUTH_TYPE(8715, "不支持的认证方式"),
// 党建声音 前端提示 88段 // 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"), DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/KcScreenController.java

@ -1,6 +1,7 @@
package com.epmet.datareport.controller.screen; package com.epmet.datareport.controller.screen;
import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth; import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.extappauth.annotation.InternalAppRequestAuth;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
@ -75,6 +76,7 @@ public class KcScreenController {
* @return * @return
*/ */
@ExternalAppRequestAuth @ExternalAppRequestAuth
@InternalAppRequestAuth
@PostMapping("issue/summary") @PostMapping("issue/summary")
public Result getIssueSummary(ExternalAppRequestParam externalAppRequestParam) { public Result getIssueSummary(ExternalAppRequestParam externalAppRequestParam) {
String customerId = externalAppRequestParam.getCustomerId(); String customerId = externalAppRequestParam.getCustomerId();

8
epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml

@ -141,3 +141,11 @@ dingTalk:
robot: robot:
webHook: @dingTalk.robot.webHook@ webHook: @dingTalk.robot.webHook@
secret: @dingTalk.robot.secret@ secret: @dingTalk.robot.secret@
jwt:
token:
#秘钥
secret: 7016867071f0ebf1c46f123eaaf4b9d6[elink.epmet]
#token有效时长,默认7天,单位秒
expire: 604800
Loading…
Cancel
Save