refactor(auth): delegate access control to be-system

Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
This commit is contained in:
t
2026-08-21 00:41:07 +08:00
parent 3d47227fbd
commit 2bbf42b741
447 changed files with 1901 additions and 8920 deletions
+13 -11
View File
@@ -1,8 +1,12 @@
package dto
import "agent-desk/internal/pkg/enums"
import (
"code.tczkiot.com/wlw/ai-agent/identity"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type AuthPrincipal struct {
SubjectType identity.SubjectType
UserID int64
Username string
Nickname string
@@ -17,17 +21,15 @@ type WxWorkKFChannelConfig struct {
}
type WebChannelConfig struct {
Title string `json:"title"`
Subtitle string `json:"subtitle"`
ThemeColor string `json:"themeColor"`
Position string `json:"position"`
Width string `json:"width"`
UserTokenSecret string `json:"userTokenSecret,omitempty"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
ThemeColor string `json:"themeColor"`
Position string `json:"position"`
Width string `json:"width"`
}
type WechatMPChannelConfig struct {
Title string `json:"title"`
Subtitle string `json:"subtitle"`
ThemeColor string `json:"themeColor"`
UserTokenSecret string `json:"userTokenSecret,omitempty"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
ThemeColor string `json:"themeColor"`
}
-96
View File
@@ -1,96 +0,0 @@
package request
import "agent-desk/internal/pkg/enums"
type RevokeSessionRequest struct {
ID int64 `json:"id"`
}
type RevokeUserSessionsRequest struct {
UserID int64 `json:"userId"`
}
type CreateUserRequest struct {
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Mobile *string `json:"mobile"`
Email *string `json:"email"`
Remark string `json:"remark"`
RoleIDs []int64 `json:"roleIds"`
}
type UpdateUserRequest struct {
ID int64 `json:"id"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Mobile *string `json:"mobile"`
Email *string `json:"email"`
Remark string `json:"remark"`
}
type DeleteUserRequest struct {
ID int64 `json:"id"`
}
type UpdateUserStatusRequest struct {
ID int64 `json:"id"`
Status int `json:"status"`
}
type ChangePasswordRequest struct {
Password string `json:"password"`
}
type AssignRoleRequest struct {
UserID int64 `json:"userId"`
RoleIDs []int64 `json:"roleIds"`
}
type CreateRoleRequest struct {
Name string `json:"name"`
Code string `json:"code"`
Remark string `json:"remark"`
}
type UpdateRoleRequest struct {
ID int64 `json:"id"`
Name string `json:"name"`
SortNo int `json:"sortNo"`
Remark string `json:"remark"`
}
type DeleteRoleRequest struct {
ID int64 `json:"id"`
}
type UpdateRoleStatusRequest struct {
ID int64 `json:"id"`
Status enums.Status `json:"status"`
}
type AssignPermissionRequest struct {
RoleID int64 `json:"roleId"`
PermissionIDs []int64 `json:"permissionIds"`
}
type CreateConversationTagRequest struct {
Name string `json:"name"`
Color string `json:"color"`
Status int `json:"status"`
SortNo int `json:"sortNo"`
Remark string `json:"remark"`
}
type UpdateConversationTagRequest struct {
ID int64 `json:"id"`
Name string `json:"name"`
Color string `json:"color"`
Status int `json:"status"`
SortNo int `json:"sortNo"`
Remark string `json:"remark"`
}
type DeleteConversationTagRequest struct {
ID int64 `json:"id"`
}
+1 -1
View File
@@ -1,6 +1,6 @@
package request
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CreateAgentProfileRequest struct {
UserID int64 `json:"userId"`
@@ -1,6 +1,6 @@
package request
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type SaveAgentRunQualityFeedbackRequest struct {
AgentRunID int64 `json:"agentRunId"`
+1 -1
View File
@@ -1,6 +1,6 @@
package request
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AIAgentMCPToolRequest struct {
ToolCode string `json:"toolCode"`
@@ -1,6 +1,6 @@
package request
import "agent-desk/internal/ai/workflow/dsl"
import "code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/dsl"
type CreateAIWorkflowRequest struct {
Name string `json:"name"`
-14
View File
@@ -1,14 +0,0 @@
package request
type LoginRequest struct {
Username string `json:"username"`
Password string `json:"password"`
}
type WxWorkExchangeRequest struct {
Ticket string `json:"ticket"`
}
type OIDCExchangeRequest struct {
Ticket string `json:"ticket"`
}
@@ -28,10 +28,6 @@ type DeleteChannelRequest struct {
ID int64 `json:"id"`
}
type ResetChannelUserTokenSecretRequest struct {
ID int64 `json:"id"`
}
type ChannelMessageOutboxActionRequest struct {
ID int64 `json:"id"`
}
@@ -3,7 +3,7 @@ package request
import (
"io"
"agent-desk/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type CreateKnowledgeBaseRequest struct {
+1 -1
View File
@@ -1,6 +1,6 @@
package request
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type MessageListRequest struct {
ConversationID int64 `json:"conversationId"`
@@ -1,6 +1,6 @@
package request
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type QuickReplyListRequest struct {
GroupName string `json:"groupName"`
@@ -1,63 +0,0 @@
package response
import "agent-desk/internal/pkg/enums"
type PermissionResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
Type string `json:"type"`
GroupName string `json:"groupName"`
Method string `json:"method"`
ApiPath string `json:"apiPath"`
Status enums.Status `json:"status"`
SortNo int `json:"sortNo"`
}
type PermissionSyncResponse struct {
Created int `json:"created"`
Updated int `json:"updated"`
RolePermissionsAdded int `json:"rolePermissionsAdded"`
}
type RoleResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
Status enums.Status `json:"status"`
IsSystem bool `json:"isSystem"`
SortNo int `json:"sortNo"`
Permissions []string `json:"permissions,omitempty"`
}
type UserResponse struct {
ID int64 `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Mobile string `json:"mobile,omitempty"`
Email string `json:"email,omitempty"`
Status enums.Status `json:"status"`
LastLoginAt string `json:"lastLoginAt,omitempty"`
LastLoginIP string `json:"lastLoginIp,omitempty"`
Roles []RoleResponse `json:"roles,omitempty"`
Permissions []string `json:"permissions,omitempty"`
}
// CreateUserResultResponse 创建用户成功响应;password 仅在本次响应中返回一次。
type CreateUserResultResponse struct {
User *UserResponse `json:"user"`
Password string `json:"password"`
}
type SessionResponse struct {
ID int64 `json:"id"`
UserID int64 `json:"userId"`
Username string `json:"username"`
ClientType string `json:"clientType"`
ClientIP string `json:"clientIp"`
UserAgent string `json:"userAgent"`
ExpiredAt string `json:"expiredAt"`
RevokedAt string `json:"revokedAt"`
LastSeenAt string `json:"lastSeenAt"`
}
+8 -1
View File
@@ -1,6 +1,13 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AgentUserOptionResponse struct {
ID int64 `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
}
type AgentProfileResponse struct {
ID int64 `json:"id"`
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AgentRunResponse struct {
ID int64 `json:"id"`
+2 -2
View File
@@ -1,8 +1,8 @@
package response
import (
"agent-desk/internal/models"
"agent-desk/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/models"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type AIAgentTeamResponse struct {
@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"
"agent-desk/internal/models"
"code.tczkiot.com/wlw/ai-agent/internal/models"
)
func TestBuildAIConfigResponseOmitsAPIKey(t *testing.T) {
@@ -1,10 +1,10 @@
package response
import (
"agent-desk/internal/ai/workflow/dsl"
workflowregistry "agent-desk/internal/ai/workflow/registry"
workflowvalidator "agent-desk/internal/ai/workflow/validator"
"agent-desk/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/dsl"
workflowregistry "code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/registry"
workflowvalidator "code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/validator"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type AIWorkflowResponse struct {
+1 -1
View File
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AssetResponse struct {
ID int64 `json:"id"`
+1 -22
View File
@@ -1,26 +1,5 @@
package response
import "agent-desk/internal/pkg/enums"
type AuthUserResponse struct {
ID int64 `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Status enums.Status `json:"status"`
Roles []string `json:"roles"`
}
type LoginResponse struct {
AccessToken string `json:"accessToken"`
ExpiresAt string `json:"expiresAt"`
User *AuthUserResponse `json:"user"`
Permissions []string `json:"permissions"`
Roles []string `json:"roles"`
}
type PublicConfigResponse struct {
Language string `json:"language"`
WxWorkEnabled bool `json:"wxworkEnabled"`
OIDCEnabled bool `json:"oidcEnabled"`
Language string `json:"language"`
}
@@ -1,9 +1,9 @@
package response
import (
"agent-desk/internal/models"
"agent-desk/internal/pkg/enums"
"agent-desk/internal/pkg/utils"
"code.tczkiot.com/wlw/ai-agent/internal/models"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/utils"
)
type ChannelResponse struct {
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CompanyResponse struct {
ID int64 `json:"id"`
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type ConversationTagResponse struct {
ID int64 `json:"id"`
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CustomerContactResponse struct {
ID int64 `json:"id"`
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CustomerResponse struct {
ID int64 `json:"id"`
@@ -1,13 +0,0 @@
package response
type CustomerSessionCustomerResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
}
type CustomerSessionExchangeResponse struct {
CustomerSessionToken string `json:"customerSessionToken"`
ExpiresAt string `json:"expiresAt"`
IdentityKey string `json:"identityKey"`
Customer CustomerSessionCustomerResponse `json:"customer"`
}
@@ -1,7 +1,7 @@
package response
import (
"agent-desk/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
"time"
)
+2 -2
View File
@@ -1,8 +1,8 @@
package response
import (
"agent-desk/internal/ai/mcps"
"agent-desk/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/ai/mcps"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type MCPConnectionResponse struct {
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type MessageResponse struct {
ID int64 `json:"id"`
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type QuickReplyResponse struct {
ID int64 `json:"id"`
+1 -1
View File
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type TagResponse struct {
ID int64 `json:"id"`
+1 -1
View File
@@ -1,6 +1,6 @@
package response
import "agent-desk/internal/pkg/enums"
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type TicketProgressResponse struct {
ID int64 `json:"id"`