MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / WithTokenWorkspaceID

Function WithTokenWorkspaceID

internal/server/context.go:48–53  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

46// workspace to the handler tree where existing access-control logic
47// reads it via tokenWorkspaceID(r).
48func 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

Callers 5

getSourceRequestMethod · 0.85
requestMethod · 0.85
callBothRawMethod · 0.85
callMethod · 0.85
callCopyMethod · 0.85

Calls

no outgoing calls

Tested by 5

getSourceRequestMethod · 0.68
requestMethod · 0.68
callBothRawMethod · 0.68
callMethod · 0.68
callCopyMethod · 0.68