Skip to content

Commit b50f238

Browse files
committed
polish(network-policy): fix orphaned TSDoc, trim narration comments, tidy hint JSX
1 parent ad8211b commit b50f238

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

apps/sim/lib/auth/auth.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,11 +3647,10 @@ async function getSessionImpl() {
36473647
headers: hdrs,
36483648
})
36493649

3650-
// Org IP allowlists are enforced at this chokepoint so EVERY
3651-
// session-authenticated request — the 180+ routes and layouts that call
3652-
// getSession directly, not just hybrid-auth routes — re-checks the policy.
3653-
// A denied member is treated as signed out. Impersonation sessions are
3654-
// platform tooling and exempt.
3650+
// Org IP allowlists are enforced at this chokepoint so every route and
3651+
// layout that calls getSession directly re-checks the policy, not just
3652+
// hybrid-auth routes. A denied member is treated as signed out.
3653+
// Impersonation sessions are platform tooling and exempt.
36553654
const impersonatedBy = session
36563655
? (session.session as { impersonatedBy?: string | null }).impersonatedBy
36573656
: null

apps/sim/lib/auth/network-policy.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export async function getNetworkPolicy(
9797
}
9898
}
9999

100-
/** Drops the cached policy for an org so the next read is fresh. */
101100
export function invalidateNetworkPolicyCache(organizationId: string): void {
102101
policyCache.delete(organizationId)
103102
}
@@ -108,17 +107,6 @@ export interface NetworkPolicyDecision {
108107
reason?: string
109108
}
110109

111-
/**
112-
* Enforces the member org's IP allowlist for a user. `resolveClientIp`
113-
* returns the trusted-proxy-resolved address ({@link getTrustedClientIp}
114-
* for requests, Better Auth's `session.ipAddress` at session creation).
115-
*
116-
* Fail-closed by design: when a policy is active and no trustworthy client
117-
* IP can be derived, access is denied — a spoofable or absent address must
118-
* not bypass a network restriction. `DISABLE_ORG_IP_ALLOWLIST` is the
119-
* break-glass for misconfigured proxy topologies. Non-members and orgs
120-
* without an active policy are always allowed.
121-
*/
122110
const ALLOWED: NetworkPolicyDecision = { allowed: true }
123111
const DENIED: NetworkPolicyDecision = {
124112
allowed: false,
@@ -150,6 +138,17 @@ function recordDenialAudit(userId: string, organizationId: string, clientIp: str
150138
})
151139
}
152140

141+
/**
142+
* Enforces the member org's IP allowlist for a user. `resolveClientIp`
143+
* returns the trusted-proxy-resolved address ({@link getTrustedClientIp}
144+
* for requests, Better Auth's `session.ipAddress` at session creation).
145+
*
146+
* Fail-closed by design: when a policy is active and no trustworthy client
147+
* IP can be derived, access is denied — a spoofable or absent address must
148+
* not bypass a network restriction. `DISABLE_ORG_IP_ALLOWLIST` is the
149+
* break-glass for misconfigured proxy topologies. Non-members and orgs
150+
* without an active policy are always allowed.
151+
*/
153152
export async function enforceOrgNetworkPolicy(
154153
userId: string | null | undefined,
155154
resolveClientIp: () => string | null | undefined

packages/platform-authz/src/network.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export interface CompiledAllowlist {
125125
v6: Array<{ network: bigint; prefix: number }>
126126
}
127127

128-
/** Compiles allowlist entries; malformed entries are silently skipped. */
129128
export function compileAllowlist(entries: readonly string[]): CompiledAllowlist {
130129
const compiled: CompiledAllowlist = { v4: [], v6: [] }
131130
for (const entry of entries) {

0 commit comments

Comments
 (0)