Skip to content

Commit 0901ca0

Browse files
julianknutsenclaude
andcommitted
fix: apply impersonation to public client fallback for unauthenticated reads
When the user isn't authenticated (no session cookie), the detail handler falls back to the anonymous public client which has no rig handle — so AvailableTransitions returns no actions. Now when X-Impersonate is set in hosted mode, the public client gets the impersonated rig handle so actions reflect the impersonated user's permissions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9119d86 commit 0901ca0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

internal/api/handlers.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ func (s *Server) resolveClient(w http.ResponseWriter, r *http.Request) (*sdk.Cli
2020
client, err := s.clientFunc(r)
2121
if err != nil {
2222
if r.Method == http.MethodGet && s.publicClient != nil {
23-
return s.publicClient, true
23+
c := s.publicClient
24+
// Staging impersonation: if the user isn't authenticated but
25+
// is impersonating, swap the rig handle on the public client
26+
// so actions reflect the impersonated user's permissions.
27+
if impersonate := r.Header.Get("X-Impersonate"); impersonate != "" && s.hosted {
28+
c = c.WithRigHandle(impersonate)
29+
}
30+
return c, true
2431
}
2532
writeError(w, http.StatusUnauthorized, "not authenticated")
2633
return nil, false

0 commit comments

Comments
 (0)