+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * 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 com.epmet.commons.extappauth.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 需要认证的外部请求
+ * @Author wxz
+ * @Description
+ * @Date 2020/4/23 16:17
+ **/
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ExternalAppRequestAuth {
+
+}
diff --git a/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java
new file mode 100644
index 0000000000..db9dc79da3
--- /dev/null
+++ b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java
@@ -0,0 +1,99 @@
+package com.epmet.commons.extappauth.aspect;
+
+
+import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.dto.form.ExternalAppAuthFormDTO;
+import com.epmet.dto.result.ExternalAppAuthResultDTO;
+import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Parameter;
+
+/**
+ * 外部应用请求认证切面
+ */
+@Aspect
+@Component
+@Order(100)
+public class ExternalAppRequestAuthAspect {
+
+ private static Logger logger = LoggerFactory.getLogger(ExternalAppRequestAuthAspect.class);
+
+ public static final String ACCESS_TOKEN_HEADER_KEY = "access_token";
+ public static final String APP_ID_HEADER_KEY = "appId";
+
+ @Autowired
+ private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
+
+ /**
+ * 拦截加了ExternalRequestAuth注解的方法
+ *
+ * @param point
+ * @throws Throwable
+ */
+ @Before("@annotation(com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth)")
+ public void auth(JoinPoint point) throws Throwable {
+ HttpServletRequest request = getRequest();
+ String token = request.getHeader(ACCESS_TOKEN_HEADER_KEY);
+ String appId = request.getHeader(APP_ID_HEADER_KEY);
+
+ if (StringUtils.isAnyBlank(token, appId)) {
+ throw new RenException("请求头中的token和appId不能为空");
+ }
+
+ logger.info("外部应用请求认证拦截Aspect执行,appId:{}, token:{}", appId, token);
+
+ ExternalAppAuthFormDTO form = new ExternalAppAuthFormDTO();
+ form.setAppId(appId);
+ form.setToken(token);
+ Result result = commonServiceOpenFeignClient.externalAppAuth(form);
+ if (result == null) {
+ throw new RenException("调用external鉴权服务,返回null");
+ }
+ if (!result.success()) {
+ throw new RenException(result.getInternalMsg());
+ }
+ ExternalAppAuthResultDTO authResult = result.getData();
+ if (!authResult.getSuccess()) {
+ throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_AUTH_ERROR.getCode(),
+ result.getData().getMessage());
+ }
+
+
+ // header参数赋值
+ MethodSignature signature = (MethodSignature) point.getSignature();
+ Parameter[] parameters = signature.getMethod().getParameters();
+ if (parameters != null && parameters.length != 0) {
+ for (int i = 0; i < parameters.length; i++) {
+ if (parameters[i].getType() == ExternalAppRequestParam.class) {
+ ExternalAppRequestParam requestParam = (ExternalAppRequestParam) point.getArgs()[i];
+ requestParam.setAppId(appId);
+ requestParam.setCustomerId(authResult.getCustomerId());
+ }
+ }
+ }
+ }
+
+ public HttpServletRequest getRequest() {
+ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+ ServletRequestAttributes sra = (ServletRequestAttributes) requestAttributes;
+ return sra.getRequest();
+ }
+
+}
diff --git a/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/bean/ExternalAppRequestParam.java b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/bean/ExternalAppRequestParam.java
new file mode 100644
index 0000000000..97ebf3c2c6
--- /dev/null
+++ b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/bean/ExternalAppRequestParam.java
@@ -0,0 +1,12 @@
+package com.epmet.commons.extappauth.bean;
+
+import lombok.Data;
+
+/**
+ * 外部应用请求信息
+ */
+@Data
+public class ExternalAppRequestParam {
+ private String customerId;
+ private String appId;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/ExternalRequestAuth.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/ExternalRequestAuth.java
new file mode 100644
index 0000000000..0cf03c25b7
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/ExternalRequestAuth.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2018 人人开源 http://www.renren.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.ExternalAppEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 外部应用列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+@Mapper
+public interface ExternalAppDao extends BaseDao {
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java
new file mode 100644
index 0000000000..f56aa08cb0
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.ExternalAppSecretEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 外部应用秘钥列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+@Mapper
+public interface ExternalAppSecretDao extends BaseDao {
+
+ /**
+ * 查询app对应的秘钥
+ * @param appId
+ * @return
+ */
+ ExternalAppSecretEntity getSecretsByAppId(@Param("appId") String appId);
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppEntity.java
new file mode 100644
index 0000000000..e4a4056108
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppEntity.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 外部应用列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("external_app")
+public class ExternalAppEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * APP名字
+ */
+ private String appName;
+
+ /**
+ * 客户ID
+ */
+ private String customerId;
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppSecretEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppSecretEntity.java
new file mode 100644
index 0000000000..0977e12264
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppSecretEntity.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 外部应用秘钥列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("external_app_secret")
+public class ExternalAppSecretEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * APP ID
+ */
+ private String appId;
+
+ /**
+ * 秘钥
+ */
+ private String secret;
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppAuthService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppAuthService.java
new file mode 100644
index 0000000000..aff79d5f72
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppAuthService.java
@@ -0,0 +1,9 @@
+package com.epmet.service;
+
+import com.epmet.dto.result.ExternalAppAuthResultDTO;
+
+public interface ExternalAppAuthService {
+
+ ExternalAppAuthResultDTO auth(String appId, String token);
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppSecretService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppSecretService.java
new file mode 100644
index 0000000000..7f6be4bd5a
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppSecretService.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service;
+
+
+/**
+ * 外部应用秘钥列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+public interface ExternalAppSecretService {
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
new file mode 100644
index 0000000000..5799ea0abb
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service.impl;
+
+import com.epmet.service.ExternalAppSecretService;
+import org.springframework.stereotype.Service;
+/**
+ * 外部应用秘钥列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+@Service
+public class ExternalAppSecretServiceImpl implements ExternalAppSecretService {
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
new file mode 100644
index 0000000000..1621e74e2d
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service.impl;
+
+import com.epmet.service.ExternalAppService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 外部应用列表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-08-18
+ */
+@Service
+public class ExternalAppServiceImpl implements ExternalAppService {
+
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java
new file mode 100644
index 0000000000..8ef9a4cde4
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2018 人人开源 All rights reserved.
+ *