统一全局插件列表访问权限
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-10 12:02:52 +08:00
1 parent c6071414df
commit cc47447ddd
4 files changed
+13 -8

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ const (
)
func GetPluginList(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
if !authenticatedPluginUser(ctx) || authorizeCapability(ctx, access.CapabilityPluginRead, "", false) != nil {
if !authenticatedPluginUser(ctx) || authorizeCapability(ctx, access.CapabilityPluginReadGlobal, "", false) != nil {
response.NewErrorResponse(response.NoAccessPrivileges, "\u65e0\u6743\u8bbf\u95ee", "").FPrint(w)
return
}
+2 -2
View File
@@ -115,8 +115,8 @@ func TestPluginConfigurationRejectsNonAdminAccess(t *testing.T) {
userListRecorder := httptest.NewRecorder()
GetPluginList(&context.Context{UserID: 2, Role: access.RoleUser}, userListRecorder, httptest.NewRequest(http.MethodGet, "/api/plugin/list", nil))
if !strings.Contains(userListRecorder.Body.String(), "PluginTest") {
t.Fatalf("authenticated user cannot read plugin list: body=%s", userListRecorder.Body.String())
if !strings.Contains(userListRecorder.Body.String(), "无权访问") {
t.Fatalf("ordinary user can read global plugin list: body=%s", userListRecorder.Body.String())
}
pageRecorder := httptest.NewRecorder()