Skip to content

Commit f3e3b61

Browse files
Gkrumbach07claude
andcommitted
fix(operator): grant session SA secret-read and session-create permissions
Revert the backend-side workaround and instead grant the session ServiceAccount the permissions it needs: - `create` on agenticsessions — allows sessions to spawn other sessions via backend tools - `get` on secrets — allows backend to validate ambient-runner-secrets using the caller's token (preserving user RBAC enforcement) This keeps the backend's RBAC enforcement intact while giving session ServiceAccounts the access they need for backend tool operations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8b856fa commit f3e3b61

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

components/backend/handlers/sessions.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,7 @@ func CreateSession(c *gin.Context) {
616616

617617
// Always verify the runner secrets exist (even if registry is unavailable
618618
// and requiredKeys is nil — prevents sessions without any API keys).
619-
// Use the backend's own service account (K8sClient) rather than the
620-
// caller's token — session ServiceAccounts lack secret-read permission.
621-
sec, err := K8sClient.CoreV1().Secrets(project).Get(c.Request.Context(), runnerSecretsName, v1.GetOptions{})
619+
sec, err := reqK8s.CoreV1().Secrets(project).Get(c.Request.Context(), runnerSecretsName, v1.GetOptions{})
622620
if err != nil {
623621
if errors.IsNotFound(err) {
624622
log.Printf("Session creation blocked: %s secret missing in project %s", runnerSecretsName, project)

components/operator/internal/handlers/sessions.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,13 +2455,19 @@ func regenerateRunnerToken(sessionNamespace, sessionName string, session *unstru
24552455
{
24562456
APIGroups: []string{"vteam.ambient-code"},
24572457
Resources: []string{"agenticsessions"},
2458-
Verbs: []string{"get", "list", "watch", "update", "patch"},
2458+
Verbs: []string{"get", "list", "watch", "create", "update", "patch"},
24592459
},
24602460
{
24612461
APIGroups: []string{"authorization.k8s.io"},
24622462
Resources: []string{"selfsubjectaccessreviews"},
24632463
Verbs: []string{"create"},
24642464
},
2465+
{
2466+
// Allow sessions to read runner secrets for backend API validation
2467+
APIGroups: []string{""},
2468+
Resources: []string{"secrets"},
2469+
Verbs: []string{"get"},
2470+
},
24652471
},
24662472
}
24672473
if _, err := config.K8sClient.RbacV1().Roles(sessionNamespace).Create(context.TODO(), role, v1.CreateOptions{}); err != nil {

0 commit comments

Comments
 (0)