fixed 打包后访问权限问题,升级1.0.8.

This commit is contained in:
许晓东
2023-05-19 15:20:15 +08:00
parent e186fff939
commit 6f093fbb27
15 changed files with 106 additions and 65 deletions

View File

@@ -54,12 +54,12 @@ public class AclUserController {
@Permission("acl:sasl-scram:detail")
@GetMapping("/detail")
public Object getUserDetail(@RequestParam String username) {
public Object getUserDetail(@RequestParam("username") String username) {
return aclService.getUserDetail(username);
}
@GetMapping("/scram")
public Object getSaslScramUserList(@RequestParam(required = false) String username) {
public Object getSaslScramUserList(@RequestParam(required = false, name = "username") String username) {
AclEntry entry = new AclEntry();
entry.setPrincipal(StringUtils.isNotBlank(username) ? username : null);
return aclService.getSaslScramUserList(entry);

View File

@@ -45,19 +45,19 @@ public class ConsumerController {
@Permission("group:del")
@DeleteMapping("/group")
public Object deleteConsumerGroup(@RequestParam String groupId) {
public Object deleteConsumerGroup(@RequestParam("groupId") String groupId) {
return consumerService.deleteConsumerGroup(groupId);
}
@Permission("group:client")
@GetMapping("/member")
public Object getConsumerMembers(@RequestParam String groupId) {
public Object getConsumerMembers(@RequestParam("groupId") String groupId) {
return consumerService.getConsumerMembers(groupId);
}
@Permission("group:consumer-detail")
@GetMapping("/detail")
public Object getConsumerDetail(@RequestParam String groupId) {
public Object getConsumerDetail(@RequestParam("groupId") String groupId) {
return consumerService.getConsumerDetail(groupId);
}
@@ -114,19 +114,19 @@ public class ConsumerController {
}
@GetMapping("/topic/list")
public Object getSubscribeTopicList(@RequestParam String groupId) {
public Object getSubscribeTopicList(@RequestParam("groupId") String groupId) {
return consumerService.getSubscribeTopicList(groupId);
}
@Permission({"topic:consumer-detail"})
@GetMapping("/topic/subscribed")
public Object getTopicSubscribedByGroups(@RequestParam String topic) {
public Object getTopicSubscribedByGroups(@RequestParam("topic") String topic) {
return consumerService.getTopicSubscribedByGroups(topic);
}
@Permission("group:offset-partition")
@GetMapping("/offset/partition")
public Object getOffsetPartition(@RequestParam String groupId) {
public Object getOffsetPartition(@RequestParam("groupId") String groupId) {
return consumerService.getOffsetPartition(groupId);
}
}

View File

@@ -42,7 +42,7 @@ public class OperationController {
}
@DeleteMapping("/sync/alignment")
public Object deleteAlignment(@RequestParam Long id) {
public Object deleteAlignment(@RequestParam("id") Long id) {
return operationService.deleteAlignmentById(id);
}

View File

@@ -35,7 +35,7 @@ public class TopicController {
@Permission("topic:load")
@GetMapping("/list")
public Object getTopicList(@RequestParam(required = false) String topic, @RequestParam String type) {
public Object getTopicList(@RequestParam(required = false, name = "topic") String topic, @RequestParam("type") String type) {
return topicService.getTopicList(topic, TopicType.valueOf(type.toUpperCase()));
}
@@ -47,7 +47,7 @@ public class TopicController {
@Permission("topic:partition-detail")
@GetMapping("/partition")
public Object getTopicPartitionInfo(@RequestParam String topic) {
public Object getTopicPartitionInfo(@RequestParam("topic") String topic) {
return topicService.getTopicPartitionInfo(topic.trim());
}
@@ -76,7 +76,7 @@ public class TopicController {
}
@GetMapping("/replica/assignment")
public Object getCurrentReplicaAssignment(@RequestParam String topic) {
public Object getCurrentReplicaAssignment(@RequestParam("topic") String topic) {
return topicService.getCurrentReplicaAssignment(topic);
}
@@ -94,7 +94,7 @@ public class TopicController {
@Permission("topic:send-count")
@GetMapping("/send/stats")
public Object sendStats(@RequestParam String topic) {
public Object sendStats(@RequestParam("topic") String topic) {
return topicService.sendStats(topic);
}
}

View File

@@ -73,14 +73,14 @@ public class UserManageController {
@Permission("user-manage:role:del")
@ControllerLog("删除角色")
@DeleteMapping("/role")
public Object deleteRole(@RequestParam Long id) {
public Object deleteRole(@RequestParam("id") Long id) {
return userManageService.deleteRole(id);
}
@Permission("user-manage:user:del")
@ControllerLog("删除用户")
@DeleteMapping("/user")
public Object deleteUser(@RequestParam Long id) {
public Object deleteUser(@RequestParam("id") Long id) {
return userManageService.deleteUser(id);
}

View File

@@ -1,15 +1,12 @@
package com.xuxd.kafka.console.dao.init;
import com.google.common.io.Files;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ResourceUtils;
import scala.collection.mutable.StringBuilder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -22,7 +19,7 @@ import java.util.Map;
@Slf4j
public class SqlParse {
private final String FILE = "classpath:db/data-h2.sql";
private final String FILE = "db/data-h2.sql";
private final Map<String, List<String>> sqlMap = new HashMap<>();
@@ -37,8 +34,7 @@ public class SqlParse {
String table = null;
try {
File file = ResourceUtils.getFile(FILE);
List<String> lines = Files.readLines(file, Charset.forName("UTF-8"));
List<String> lines = getSqlLines();
for (String str : lines) {
if (StringUtils.isNotEmpty(str)) {
if (str.indexOf("start--") > 0) {
@@ -61,9 +57,7 @@ public class SqlParse {
}
}
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -82,4 +76,21 @@ public class SqlParse {
private boolean isSql(String str) {
return StringUtils.isNotEmpty(str) && str.startsWith("insert");
}
private List<String> getSqlLines() throws Exception {
// File file = ResourceUtils.getFile(FILE);
// List<String> lines = Files.readLines(file, Charset.forName("UTF-8"));
List<String> lines = new ArrayList<>();
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(FILE)) {
try (InputStreamReader inputStreamReader = new InputStreamReader(inputStream)) {
try (BufferedReader reader = new BufferedReader(inputStreamReader)) {
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
}
}
}
return lines;
}
}

View File

@@ -44,6 +44,10 @@ public class AuthFilter implements Filter {
String accessToken = request.getHeader(TOKEN_HEADER);
String requestURI = request.getRequestURI();
if (isResourceRequest(requestURI)) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}
if (requestURI.startsWith(AUTH_URI_PREFIX)) {
filterChain.doFilter(servletRequest, servletResponse);
return;
@@ -63,8 +67,12 @@ public class AuthFilter implements Filter {
try {
CredentialsContext.set(credentials);
filterChain.doFilter(servletRequest, servletResponse);
}finally {
} finally {
CredentialsContext.remove();
}
}
private boolean isResourceRequest(String requestURI) {
return requestURI.contains(".") || requestURI.equals("/");
}
}