@@ -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. */
101100export 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- */
122110const ALLOWED : NetworkPolicyDecision = { allowed : true }
123111const 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+ */
153152export async function enforceOrgNetworkPolicy (
154153 userId : string | null | undefined ,
155154 resolveClientIp : ( ) => string | null | undefined
0 commit comments