Repository navigation
feat(auth): add workspace access and connection policy hooks - #10
Conversation
No blocking issues foundCommit: fd70e79 The change adds optional per-auth workspace access and connection-save hooks, plus product-guide routing and chat prompt updates. The visible access checks preserve existing membership checks and remain optional. No actionable defect or source-supported secret exposure was found in the changed lines. Change vs. PR intent: Partially aligned. The diff implements the requested optional policy hooks, but also adds product-guide retrieval and chat behavior changes beyond the stated intent. ScoresCode quality █████ 5/5 Security █████ 5/5 Optional workspace policies and product-guide evidenceflowchart LR
n0["Workspace access boundary"]
n1["Run registered access policy if present"]
n2["Continue existing workspace handling"]
n3["Connection-save transaction"]
n4["Run optional access and connection-save hooks"]
n5["Route chat using registered guide catalog"]
n6["Gather selected guides and workspace evidence"]
n7["Prepare grounded chat answer"]
n0 -->|"Check application policy"| n1
n1 -->|"Allowed or no policy registered"| n2
n3 -->|"Before connection persistence"| n4
n5 -->|"Validated guide IDs and selected tools"| n6
n6 -->|"Include guide evidence within input budget"| n7
No findings on the changed lines. View the full report in Inkspect Reviewed by Inkspect · engine v0.0.46 |
| const { adapter } = await auth.$context; | ||
| const member = await adapter.findOne<{ role: string }>({ model: "member", where: [{ field: "userId", value: session.user.id }, { field: "organizationId", value: organizationId }] }); | ||
| if (!member) throw new ReviewError(403, "You no longer have access to this workspace."); | ||
| await workspacePolicy(auth)?.assertAccess(organizationId); |
There was a problem hiding this comment.
P1 · Enforce the workspace policy on review and chat requests
The new check protects callers of organizationAccess, but reviewAccess and handleWorkspaceChat perform independent membership checks and never consult the registered policy. A member of a workspace rejected by assertAccess can still call handleRepositories or authorizeRealtime through reviewAccess, and can access chat directly. Rejecting workspaceStatus or a dashboard request does not protect those HTTP entry points. This makes the newly introduced workspace restriction bypassable.
Suggested fix
Apply the same policy after membership verification in reviewAccess and handleWorkspaceChat. Audit other independent workspace authorization paths, such as workspace-logo access, and either enforce the policy there or explicitly define and document intentional exceptions.
Verification
Register a policy whose assertAccess always rejects, then call repository, realtime authorization, and chat handlers with an otherwise valid member session. Confirm that each rejects before reading workspace data or invoking downstream services. Also confirm that these handlers retain their previous behavior without a registered policy.
Comment @inkspectsi review again after pushing your changes to request another review.
Expose optional hooks for workspace access and verified connections. Keep the existing access behavior for hosts that omit the hooks.