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:
@@ -1,7 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"agent-desk/internal/pkg/enums"
|
||||
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -9,17 +9,14 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Language string `yaml:"language"`
|
||||
Server ServerConfig `yaml:"server"`
|
||||
DB DBConfig `yaml:"db"`
|
||||
Logger LoggerConfig `yaml:"logger"`
|
||||
Auth AuthConfig `yaml:"auth"`
|
||||
Storage StorageConfig `yaml:"storage"`
|
||||
VectorDB VectorDBConfig `yaml:"vectorDB"`
|
||||
MCP MCPConfig `yaml:"mcp"`
|
||||
WxWork WxWorkConfig `yaml:"wxWork"`
|
||||
OIDC OIDCConfig `yaml:"oidc"`
|
||||
CustomerSession CustomerSessionConfig `yaml:"customerSession"`
|
||||
Language string `yaml:"language"`
|
||||
Server ServerConfig `yaml:"server"`
|
||||
DB DBConfig `yaml:"db"`
|
||||
Logger LoggerConfig `yaml:"logger"`
|
||||
Storage StorageConfig `yaml:"storage"`
|
||||
VectorDB VectorDBConfig `yaml:"vectorDB"`
|
||||
MCP MCPConfig `yaml:"mcp"`
|
||||
WxWork WxWorkConfig `yaml:"wxWork"`
|
||||
}
|
||||
|
||||
func (c Config) LanguageOrDefault() string {
|
||||
@@ -82,32 +79,6 @@ type LoggerConfig struct {
|
||||
AddSource bool `yaml:"addSource"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
TokenTTLHours int `yaml:"tokenTTLHours"`
|
||||
MaxFailedAttempts int `yaml:"maxFailedAttempts"`
|
||||
CredentialLockMinute int `yaml:"credentialLockMinute"`
|
||||
}
|
||||
|
||||
type CustomerSessionConfig struct {
|
||||
Secret string `yaml:"secret"`
|
||||
TTLMinutes int `yaml:"ttlMinutes"`
|
||||
RefreshThresholdMinutes int `yaml:"refreshThresholdMinutes"`
|
||||
}
|
||||
|
||||
func (c CustomerSessionConfig) TTL() int {
|
||||
if c.TTLMinutes <= 0 {
|
||||
return 120
|
||||
}
|
||||
return c.TTLMinutes
|
||||
}
|
||||
|
||||
func (c CustomerSessionConfig) RefreshThreshold() int {
|
||||
if c.RefreshThresholdMinutes <= 0 {
|
||||
return 30
|
||||
}
|
||||
return c.RefreshThresholdMinutes
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
Default enums.AssetProvider `yaml:"default"`
|
||||
MaxUploadSizeMB int64 `yaml:"maxUploadSizeMB"`
|
||||
@@ -171,27 +142,10 @@ type MCPServerConfig struct {
|
||||
Headers map[string]string `yaml:"headers"`
|
||||
}
|
||||
|
||||
type OIDCConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Issuer string `yaml:"issuer"`
|
||||
ClientID string `yaml:"clientId"`
|
||||
ClientSecret string `yaml:"clientSecret"`
|
||||
RedirectURL string `yaml:"redirectUrl"`
|
||||
StateSecret string `yaml:"stateSecret"`
|
||||
Scopes []string `yaml:"scopes"`
|
||||
}
|
||||
|
||||
// WxWorkConfig 定义企业微信接入配置。
|
||||
//
|
||||
// 当前主要用于后台管理台的企业微信登录流程:
|
||||
// 1. /api/auth/wxwork/login 生成企业微信授权地址
|
||||
// 2. 企业微信回调到 OAuthRedirect
|
||||
// 3. 后端通过 code 换取企业成员身份并完成系统登录
|
||||
//
|
||||
// 其中 OAuthRedirect、CorpID、CorpSecret、AgentID 为登录流程核心配置。
|
||||
// WxWorkConfig defines the WeCom application used for customer-service
|
||||
// callbacks and notifications. Dashboard login is owned by be-system.
|
||||
type WxWorkConfig struct {
|
||||
// Enabled 表示是否启用企业微信登录能力。
|
||||
// false 时不会初始化企业微信 SDK,相关登录接口不可用。
|
||||
// Enabled controls whether the WeCom SDK is initialized.
|
||||
Enabled bool `yaml:"enabled"`
|
||||
// CorpID 为企业微信公司 ID,例如 wwxxxxxxxxxxxxxxxx。
|
||||
CorpID string `yaml:"corpId"`
|
||||
@@ -199,20 +153,11 @@ type WxWorkConfig struct {
|
||||
CorpSecret string `yaml:"corpSecret"`
|
||||
// AgentID 为企业微信自建应用 AgentID。
|
||||
AgentID string `yaml:"agentId"`
|
||||
// OAuthRedirect 为企业微信网页授权回调地址。
|
||||
// 必须填写完整 URL,且通常指向后端接口 /api/auth/wxwork/callback。
|
||||
OAuthRedirect string `yaml:"oauthRedirect"`
|
||||
// StateSecret 为登录 state 的签名密钥,用于防止篡改和重放。
|
||||
// 建议填写独立随机字符串;留空时业务代码会退回使用 CorpSecret。
|
||||
StateSecret string `yaml:"stateSecret"`
|
||||
// RSAPrivateKey 为企业微信回调解密私钥。
|
||||
// 当前登录流程未使用,保留给消息回调等场景。
|
||||
RSAPrivateKey string `yaml:"rsaPrivateKey"`
|
||||
// Token 为企业微信回调 Token。
|
||||
// 当前登录流程未使用,保留给消息回调等场景。
|
||||
Token string `yaml:"token"`
|
||||
// EncodingAESKey 为企业微信消息加解密密钥。
|
||||
// 当前登录流程未使用,保留给消息回调等场景。
|
||||
EncodingAESKey string `yaml:"encodingAESKey"`
|
||||
// Notify 为企业微信应用消息通知配置。
|
||||
Notify WxWorkNotifyConfig `yaml:"notify"`
|
||||
|
||||
Reference in New Issue
Block a user