Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix Bug]Don't filter out Visualis-share URLs #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,19 @@ public boolean supportsParameter(MethodParameter parameter) {

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
HttpServletRequest httpServletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
try
{
return (User)userMapper.selectByUsername(SecurityFilter.getLoginUsername(webRequest.getNativeRequest(HttpServletRequest.class)));
return (User)userMapper.selectByUsername(SecurityFilter.getLoginUsername(httpServletRequest));
}catch (Throwable e){
log.error("Failed to get user:",e);
throw e;
// 普通分享页特殊处理,可以不需要登录(不影响授权分享页,授权分享依旧需要登录)
if (httpServletRequest != null && httpServletRequest.getRequestURI().contains("/share/")) {
log.warn("Fallback to share page User handler for {}", httpServletRequest.getRequestURI());
return (User) webRequest.getAttribute(Consts.CURRENT_USER, RequestAttributes.SCOPE_REQUEST);
}else {
throw e;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public ShareWidget getShareWidget(String token, User user) throws NotFoundExcept
}

if (!StringUtils.isEmpty(shareInfo.getSharedUserName())) {
if (!shareInfo.getSharedUserName().equals(user.getUsername())) {
if (user == null || !shareInfo.getSharedUserName().equals(user.getUsername())) {
throw new ForbiddenExecption("ERROR Permission denied");
}
}
Expand Down Expand Up @@ -216,7 +216,7 @@ public ShareDisplay getShareDisplay(String token, User user) throws NotFoundExce
Display display = displayMapper.getById(displayId);

if (!StringUtils.isEmpty(shareInfo.getSharedUserName())) {
if (!shareInfo.getSharedUserName().equals(user.getUsername())) {
if (user == null || !shareInfo.getSharedUserName().equals(user.getUsername())) {
throw new ForbiddenExecption("ERROR Permission denied");
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ public ShareDashboard getShareDashboard(String token, User user) throws NotFound
}

if (!StringUtils.isEmpty(shareInfo.getSharedUserName())) {
if (!shareInfo.getSharedUserName().equals(user.getUsername())) {
if (user == null || !shareInfo.getSharedUserName().equals(user.getUsername())) {
throw new ForbiddenExecption("ERROR Permission denied");
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ public Paginate<Map<String, Object>> getShareData(String token, ViewExecuteParam
}

if (!StringUtils.isEmpty(shareInfo.getSharedUserName())) {
if (!shareInfo.getSharedUserName().equals(user.getUsername())) {
if (user == null || !shareInfo.getSharedUserName().equals(user.getUsername())) {
throw new ForbiddenExecption("ERROR Permission denied");
}
}
Expand Down Expand Up @@ -433,7 +433,7 @@ public String generationShareDataCsv(ViewExecuteParam executeParam, User user, S
}

if (!StringUtils.isEmpty(shareInfo.getSharedUserName())) {
if (!shareInfo.getSharedUserName().equals(user.getUsername())) {
if (user == null || !shareInfo.getSharedUserName().equals(user.getUsername())) {
throw new ForbiddenExecption("ERROR Permission denied");
}
}
Expand Down Expand Up @@ -496,7 +496,7 @@ public ResultMap getDistinctValue(String token, Long viewId, DistinctParam param
}

if (!StringUtils.isEmpty(shareInfo.getSharedUserName())) {
if (!shareInfo.getSharedUserName().equals(user.getUsername())) {
if (user == null || !shareInfo.getSharedUserName().equals(user.getUsername())) {
resultFail(user, request, HttpCodeEnum.FORBIDDEN).message("ERROR Permission denied");
}
}
Expand Down