fix: allow agent JWT to use attached online_db_id (Z14c)
Agent tokens use agent_id as user_id while Binding is under the human member; authorize schema/push/ensure against the agent's mounted OnlineDBID. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
20
platform/internal/handler/agent_online_acl_test.go
Normal file
20
platform/internal/handler/agent_online_acl_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"aijianzhan/platform/internal/authx"
|
||||
)
|
||||
|
||||
func TestAgentOwnsOnlineDBUsesContextAgent(t *testing.T) {
|
||||
// 无 Agents store 时必须安全返回 false
|
||||
r := httptest.NewRequest(http.MethodPost, "/", nil)
|
||||
ctx := authx.WithFullClaims(context.Background(), 2, 99, authx.Role智能体, 99, 0, []string{authx.Perm数据同步})
|
||||
r = r.WithContext(ctx)
|
||||
if agentOwnsOnlineDB(nil, r, 2, "ch1", "ch1_u3") {
|
||||
t.Fatal("expected false without svc")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user