mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
(improvement)(headless) Query metric/dimension by id in SchemaController and update api header check (#608)
* (improvement)(headless) Query metric/dimension by id in SchemaController and update api header check * (improvement)(headless) Fix the issue where metrics were not recognized when the result field contained an aggregate function. --------- Co-authored-by: jolunoluo
This commit is contained in:
@@ -24,4 +24,13 @@ public class AuthenticationConfig {
|
||||
@Value("${authentication.token.http.header.key:Authorization}")
|
||||
private String tokenHttpHeaderKey;
|
||||
|
||||
@Value("${authentication.app.appId:appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${authentication.app.timestamp:timestamp}")
|
||||
private String timestamp;
|
||||
|
||||
@Value("${authentication.app.signature:signature}")
|
||||
private String signature;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.tencent.supersonic.auth.api.authentication.utils;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.service.UserStrategy;
|
||||
import com.tencent.supersonic.common.pojo.SysParameter;
|
||||
import com.tencent.supersonic.common.service.SysParameterService;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -14,7 +19,14 @@ public final class UserHolder {
|
||||
}
|
||||
|
||||
public static User findUser(HttpServletRequest request, HttpServletResponse response) {
|
||||
return REPO.findUser(request, response);
|
||||
User user = REPO.findUser(request, response);
|
||||
SysParameterService sysParameterService = ContextUtils.getBean(SysParameterService.class);
|
||||
SysParameter sysParameter = sysParameterService.getSysParameter();
|
||||
if (!CollectionUtils.isEmpty(sysParameter.getAdmins())
|
||||
&& sysParameter.getAdmins().contains(user.getName())) {
|
||||
user.setIsAdmin(1);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,16 +5,17 @@ import com.tencent.supersonic.auth.api.authentication.constant.UserConstants;
|
||||
import com.tencent.supersonic.auth.authentication.service.UserServiceImpl;
|
||||
import com.tencent.supersonic.auth.authentication.utils.UserTokenUtils;
|
||||
import com.tencent.supersonic.common.util.S2ThreadContext;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.catalina.connector.RequestFacade;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.apache.tomcat.util.http.MimeHeaders;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class AuthenticationInterceptor implements HandlerInterceptor {
|
||||
@@ -58,6 +59,11 @@ public abstract class AuthenticationInterceptor implements HandlerInterceptor {
|
||||
return "true".equalsIgnoreCase(internal);
|
||||
}
|
||||
|
||||
protected boolean isAppRequest(HttpServletRequest request) {
|
||||
String appId = request.getHeader(authenticationConfig.getAppId());
|
||||
return StringUtils.isNotBlank(appId);
|
||||
}
|
||||
|
||||
protected void reflectSetparam(HttpServletRequest request, String key, String value) {
|
||||
try {
|
||||
if (request instanceof StandardMultipartHttpServletRequest) {
|
||||
|
||||
@@ -10,12 +10,12 @@ import com.tencent.supersonic.common.pojo.exception.AccessException;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
import com.tencent.supersonic.common.util.S2ThreadContext;
|
||||
import com.tencent.supersonic.common.util.ThreadContext;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Slf4j
|
||||
public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor {
|
||||
@@ -35,7 +35,10 @@ public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor
|
||||
setFakerUser(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isAppRequest(request)) {
|
||||
setFakerUser(request);
|
||||
return true;
|
||||
}
|
||||
if (handler instanceof HandlerMethod) {
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
Method method = handlerMethod.getMethod();
|
||||
|
||||
Reference in New Issue
Block a user