WithTokenWorkspaceID returns ctx decorated with a workspace-scope hint, mirroring TokenAuth's behaviour for workspace-scoped API tokens. Pass an empty string to clear (overrides any previous scope-binding to ""; downstream readers via tokenWorkspaceID(r) see the same "no scope" they would for a neve
(ctx context.Context, workspaceID string)
| 46 | // workspace to the handler tree where existing access-control logic |
| 47 | // reads it via tokenWorkspaceID(r). |
| 48 | func WithTokenWorkspaceID(ctx context.Context, workspaceID string) context.Context { |
| 49 | // Always overwrite — passing "" must clear a stale scope set |
| 50 | // further up the context chain. Returning ctx unchanged on the |
| 51 | // empty path was a bug Codex caught in PR #343 review round 4. |
| 52 | return context.WithValue(ctx, ctxTokenWorkspaceID, workspaceID) |
| 53 | } |
| 54 | |
| 55 | // CurrentUserFromContext returns the user attached by WithCurrentUser |
| 56 | // (or by the standard auth middleware), and a boolean signalling |
no outgoing calls