Skip to content

Commit 736e686

Browse files
jeremyederclaude
andcommitted
fix(backend): add RBAC/BOT_TOKEN documentation to CodeRabbit credential fetch
Matches the comment pattern used in GetJiraCredentialsForSession and GetGitLabTokenForSession to explain the BOT_TOKEN RBAC edge case. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aeb27a5 commit 736e686

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

components/backend/handlers/runtime_credentials.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,17 @@ func GetCodeRabbitCredentialsForSession(c *gin.Context) {
568568
return
569569
}
570570

571+
// Verify authenticated user owns this session (RBAC: prevent accessing other users' credentials)
572+
// Note: BOT_TOKEN (session ServiceAccount) won't have userID in context, which is fine -
573+
// BOT_TOKEN is already scoped to this specific session via RBAC
571574
authenticatedUserID := c.GetString("userID")
572575
if authenticatedUserID != "" && authenticatedUserID != userID {
573576
log.Printf("RBAC violation: user %s attempted to access credentials for session owned by %s", authenticatedUserID, userID)
574577
c.JSON(http.StatusForbidden, gin.H{"error": "Access denied: session belongs to different user"})
575578
return
576579
}
580+
// If authenticatedUserID is empty, this is likely BOT_TOKEN (session-scoped ServiceAccount)
581+
// which is allowed because it's already restricted to this session via K8s RBAC
577582

578583
creds, err := GetCodeRabbitCredentials(c.Request.Context(), userID)
579584
if err != nil {

0 commit comments

Comments
 (0)