diff --git a/backend/src/main/java/io/dataease/auth/filter/F2CLinkFilter.java b/backend/src/main/java/io/dataease/auth/filter/F2CLinkFilter.java index c7a8560cf6..9d712977a6 100644 --- a/backend/src/main/java/io/dataease/auth/filter/F2CLinkFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/F2CLinkFilter.java @@ -9,8 +9,6 @@ import io.dataease.auth.util.LinkUtil; import io.dataease.base.domain.PanelLink; import io.dataease.commons.utils.LogUtil; import org.apache.shiro.web.filter.authc.AnonymousFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; @@ -26,9 +24,9 @@ public class F2CLinkFilter extends AnonymousFilter { HttpServletRequest req = (HttpServletRequest) request; String linkToken = req.getHeader(LINK_TOKEN_KEY); DecodedJWT jwt = JWT.decode(linkToken); - Claim resourceId = jwt.getClaim("resourceId"); - String id = resourceId.asString(); - PanelLink panelLink = LinkUtil.queryLink(id); + String resourceId = jwt.getClaim("resourceId").asString(); + Long userId = jwt.getClaim("userId").asLong(); + PanelLink panelLink = LinkUtil.queryLink(resourceId, userId); if (ObjectUtil.isEmpty(panelLink)) return false; String pwd; if (!panelLink.getEnablePwd()) { @@ -37,7 +35,7 @@ public class F2CLinkFilter extends AnonymousFilter { } else { pwd = panelLink.getPwd(); } - return JWTUtils.verifyLink(linkToken, id, pwd); + return JWTUtils.verifyLink(linkToken, resourceId, userId, pwd); } catch (Exception e) { LogUtil.error(e); } diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index dd10059a6f..9e27662bf1 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -126,16 +126,24 @@ public class JWTUtils { } } - public static String signLink(String resourceId, String secret) { + public static String signLink(String resourceId, Long userId, String secret) { Algorithm algorithm = Algorithm.HMAC256(secret); - return JWT.create().withClaim("resourceId", resourceId).sign(algorithm); + if(userId == null){ + return JWT.create().withClaim("resourceId", resourceId).sign(algorithm); + }else { + return JWT.create().withClaim("resourceId", resourceId).withClaim("userId", userId).sign(algorithm); + } } - public static boolean verifyLink(String token, String resourceId, String secret) { + public static boolean verifyLink(String token, String resourceId, Long userId, String secret) { Algorithm algorithm = Algorithm.HMAC256(secret); - JWTVerifier verifier = JWT.require(algorithm) - .withClaim("resourceId", resourceId) - .build(); + JWTVerifier verifier; + if(userId == null){ + verifier = JWT.require(algorithm).withClaim("resourceId", resourceId).build(); + }else { + verifier = JWT.require(algorithm).withClaim("resourceId", resourceId).withClaim("userId", userId).build(); + } + try { verifier.verify(token); return true; diff --git a/backend/src/main/java/io/dataease/auth/util/LinkUtil.java b/backend/src/main/java/io/dataease/auth/util/LinkUtil.java index df29abc08a..ed6b4a679f 100644 --- a/backend/src/main/java/io/dataease/auth/util/LinkUtil.java +++ b/backend/src/main/java/io/dataease/auth/util/LinkUtil.java @@ -16,7 +16,7 @@ public class LinkUtil { LinkUtil.panelLinkService = panelLinkService; } - public static PanelLink queryLink(String resourceId) { - return panelLinkService.findOne(resourceId); + public static PanelLink queryLink(String resourceId, Long user) { + return panelLinkService.findOne(resourceId, user); } } diff --git a/backend/src/main/java/io/dataease/base/domain/PanelLink.java b/backend/src/main/java/io/dataease/base/domain/PanelLink.java index 966a8c59c3..20b5b3ac22 100644 --- a/backend/src/main/java/io/dataease/base/domain/PanelLink.java +++ b/backend/src/main/java/io/dataease/base/domain/PanelLink.java @@ -15,5 +15,7 @@ public class PanelLink implements Serializable { private Long overTime; + private Long userId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/PanelLinkExample.java b/backend/src/main/java/io/dataease/base/domain/PanelLinkExample.java index 99e7fb3f91..a60944e56c 100644 --- a/backend/src/main/java/io/dataease/base/domain/PanelLinkExample.java +++ b/backend/src/main/java/io/dataease/base/domain/PanelLinkExample.java @@ -423,6 +423,66 @@ public class PanelLinkExample { addCriterion("over_time not between", value1, value2, "overTime"); return (Criteria) this; } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/dataease/base/domain/PanelLinkMapping.java b/backend/src/main/java/io/dataease/base/domain/PanelLinkMapping.java index 8af3488aa4..7321d46342 100644 --- a/backend/src/main/java/io/dataease/base/domain/PanelLinkMapping.java +++ b/backend/src/main/java/io/dataease/base/domain/PanelLinkMapping.java @@ -9,5 +9,7 @@ public class PanelLinkMapping implements Serializable { private String resourceId; + private Long userId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/PanelLinkMappingExample.java b/backend/src/main/java/io/dataease/base/domain/PanelLinkMappingExample.java index da9e2da4ca..a4e98885dc 100644 --- a/backend/src/main/java/io/dataease/base/domain/PanelLinkMappingExample.java +++ b/backend/src/main/java/io/dataease/base/domain/PanelLinkMappingExample.java @@ -233,6 +233,66 @@ public class PanelLinkMappingExample { addCriterion("resource_id not between", value1, value2, "resourceId"); return (Criteria) this; } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.java b/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.java index 1202095bf2..55a71608aa 100644 --- a/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.java +++ b/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.java @@ -10,21 +10,13 @@ public interface PanelLinkMapper { int deleteByExample(PanelLinkExample example); - int deleteByPrimaryKey(String resourceId); - int insert(PanelLink record); int insertSelective(PanelLink record); List selectByExample(PanelLinkExample example); - PanelLink selectByPrimaryKey(String resourceId); - int updateByExampleSelective(@Param("record") PanelLink record, @Param("example") PanelLinkExample example); int updateByExample(@Param("record") PanelLink record, @Param("example") PanelLinkExample example); - - int updateByPrimaryKeySelective(PanelLink record); - - int updateByPrimaryKey(PanelLink record); } \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.xml b/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.xml index eedc1062fe..c0bc1c485d 100644 --- a/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/PanelLinkMapper.xml @@ -2,11 +2,12 @@ - + + @@ -67,7 +68,7 @@ - resource_id, `valid`, enable_pwd, pwd, over_time + resource_id, `valid`, enable_pwd, pwd, over_time, user_id - - - delete from panel_link - where resource_id = #{resourceId,jdbcType=VARCHAR} - delete from panel_link @@ -101,9 +92,11 @@ insert into panel_link (resource_id, `valid`, enable_pwd, - pwd, over_time) + pwd, over_time, user_id + ) values (#{resourceId,jdbcType=VARCHAR}, #{valid,jdbcType=BIT}, #{enablePwd,jdbcType=BIT}, - #{pwd,jdbcType=VARCHAR}, #{overTime,jdbcType=BIGINT}) + #{pwd,jdbcType=VARCHAR}, #{overTime,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT} + ) insert into panel_link @@ -123,6 +116,9 @@ over_time, + + user_id, + @@ -140,6 +136,9 @@ #{overTime,jdbcType=BIGINT}, + + #{userId,jdbcType=BIGINT}, + select @@ -97,8 +98,10 @@ - insert into panel_link_mapping (id, resource_id) - values (#{id,jdbcType=BIGINT}, #{resourceId,jdbcType=VARCHAR}) + insert into panel_link_mapping (id, resource_id, user_id + ) + values (#{id,jdbcType=BIGINT}, #{resourceId,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT} + ) insert into panel_link_mapping @@ -109,6 +112,9 @@ resource_id, + + user_id, + @@ -117,6 +123,9 @@ #{resourceId,jdbcType=VARCHAR}, + + #{userId,jdbcType=BIGINT}, +