feat(auth): org IP allowlisting — member network restrictions#5872
feat(auth): org IP allowlisting — member network restrictions#5872waleedlatif1 wants to merge 8 commits into
Conversation
…sign-in, sessions, API keys, realtime
…ntry labels, denial audit events, shared proxy helpers, lazy IP resolution
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@cursor review |
PR SummaryHigh Risk Overview Enforcement is wired through Also adds enterprise docs, navigation/registry entries, env flags for self-hosted, migration Reviewed by Cursor Bugbot for commit a073439. Configure here. |
Greptile SummaryThis PR adds organization IP allowlisting across member authentication paths. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (9): Last reviewed commit: "fix(realtime): bound socket denial-audit..." | Re-trigger Greptile |
Greptile SummaryThis PR adds organization-level IP access restrictions across authenticated product surfaces. The main changes are:
Confidence Score: 4/5The realtime enforcement path and mapped-address matching need fixes before merging.
apps/realtime/src/middleware/network-policy.ts; packages/platform-authz/src/network.ts
|
| Filename | Overview |
|---|---|
| apps/realtime/src/middleware/network-policy.ts | Adds realtime policy enforcement, but unresolved proxy chains can fall back to an allowed proxy address and denials are not audited. |
| packages/platform-authz/src/network.ts | Adds shared IP and CIDR matching, with an inconsistency between accepted mapped IPv6 CIDRs and mapped client-address matching. |
| apps/sim/lib/auth/network-policy.ts | Adds cached app-side policy resolution, trusted-IP checks, entitlement gating, and throttled denial auditing. |
| apps/sim/app/api/organizations/[id]/network-policy/route.ts | Adds member reads and enterprise-admin updates with lockout prevention and policy-version invalidation. |
| apps/sim/lib/auth/auth.ts | Adds policy enforcement during session creation and at the central session-read path. |
| apps/sim/lib/auth/hybrid.ts | Adds network-policy enforcement to successful API-key authentication. |
| apps/sim/ee/network-policy/components/network-policy-settings.tsx | Adds the enterprise allowlist editor with validation and save or discard behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Authenticated request] --> B{Authentication path}
B -->|Session or API key| C[App policy enforcement]
B -->|Socket handshake| D[Realtime policy enforcement]
C --> E[Load member organization policy]
D --> E
E --> F[Resolve trusted client IP]
F --> G{Address matches allowlist?}
G -->|Yes| H[Allow access]
G -->|No or unresolved| I[Deny and record audit event]
F -. unresolved socket chain .-> J[Fallback to proxy peer]
J -. proxy may be allowed .-> H
Reviews (1): Last reviewed commit: "polish(network-policy): fix orphaned TSD..." | Re-trigger Greptile
…pped-CIDR matching, realtime fail-open+audit consistency, drop dead exports
|
Additional fix in this round from an internal enforcement-coverage audit (not flagged by review, but a real bypass): the public |
|
@cursor review |
…(covers client session), match realtime break-glass to isTruthy
|
@cursor review |
…on (app-side primary socket gate)
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2ca9a67. Configure here.
|
@greptile review |
…extual forms (compressed/expanded/hex) match uniformly
|
@greptile review |
|
@cursor review |
|
@greptile review |
|
@cursor review |
|
@greptile review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a073439. Configure here.
Summary
# labelper entry, up to 200). When enabled, org members can only sign in and use Sim from allowed addresses.getSessionchokepoint so every session-authenticated route and layout re-checks the policy (not just hybrid-auth routes) — a denied member resolves as signed out. Also enforced at session establishment (sign-in hook), the API-key auth path (checkHybridAuth), and the realtime Socket.IO handshake.superRefine). The settings page shows the caller's current IP.AUTH_TRUSTED_PROXIES), access is denied.DISABLE_ORG_IP_ALLOWLISTis the break-glass (read at call time, no restart needed).organization.ip_access.denied, throttled per-member) plus the policy-change event, so security teams see who's blocked and from where.AUTH_TRUSTED_PROXIES; sharedparseTrustedProxies/buildIpResolutionOptionshelpers replace three duplicated parse blocks.organization.network_policy_settingsjson column. ReusessecurityPolicyVersion(from feat(auth): org session policies — lifetime/idle limits, org-wide revocation #5862) so policy changes invalidate cached session cookies org-wide within ~60s.@sim/platform-authz/network(43 tests), shared by the app, the realtime server, and the contract validator (client-bundle-safe — nonode:net).Industry validation
Design cross-checked against 12 platforms' live admin docs (GitHub Enterprise, Datadog, Atlassian, Salesforce, Okta, Google Workspace, Notion, Figma, Slack, Workato, Zapier, Retool). Our core (enterprise-gated, IPv4/IPv6/CIDR, continuous enforcement incl. API keys, product-outward exemptions, hard save-time lockout guard, fail-closed + break-glass) matches or exceeds the mature implementations; Zapier and Retool Cloud don't offer this natively at all. The two gaps every mature impl has — per-entry labels and denial audit events — are both implemented here.
Type of Change
Testing
Checklist