netlify-access-control-two-layer-pattern

A reference pattern for protecting a Netlify-hosted app at two levels: limiting access to company employees and identifying each signed-in user. Netlify is a service for deploying websites and web apps.

In plain words
What is it for?
Use it when choosing how an internal Netlify app should handle employee access, per-user data, roles, invitations, and redirects.
Why use it?
It separates company-wide access control from user identity, helping avoid unnecessary double logins and unclear authentication designs.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/netlify/context-and-tools/netlify-access-control-two-layer-pattern
Clone the repo
git clone --depth 1 https://github.com/netlify/context-and-tools
Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,237 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.01237
Opus 5 $0.00012 $0.00619
Sonnet 5 $0.00005 $0.00247
Haiku 4.5 $0.00002 $0.00124

Measured 2d ago against content hash d599cb678694, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

netlify-access-control-two-layer-pattern scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

cursor/rules/netlify-access-control-two-layer-pattern.mdc · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Two-Layer Pattern: Company-Only Access + Per-User Identity

A common enterprise ask conflates two concerns:

  1. Perimeter — the deployed app should be reachable only by company employees.
  2. In-app identity — the app should tell users apart (per-user data, roles).

These are different layers (see the main skill). Below are the four ways to satisfy them on Netlify, ordered from least to most friction, plus why the naive "stack both" approach forces a double login.

Option A — Invite-only Netlify Identity (best default for "just my team")

Enable Netlify Identity in invite-only registration mode and invite only company addresses. Identity becomes the perimeter and the in-app identity: no uninvited user can sign in, and every signed-in user is a real Identity user with nf_jwt and roles.

  • Plans: all (free).
  • Logins: one.
  • Per-user identity: full (roles via app_metadata, role-based redirects via nf_jwt).
  • Tradeoffs: manual invite management; no automatic provisioning from a corporate directory; relies on invite links not being shared. Great for internal tools and small teams; doesn't scale cleanly to thousands of employees.

Option B — Auth0 extension (best for a real org with an existing IdP)

Use the Netlify Auth0 extension instead of (or alongside) Identity. Configure Auth0 to federate with the company's IdP (Okta, Entra, Google Workspace, etc.). Auth0 enforces "company-only" via its connection/organization settings and supplies per-user identity — in a single sign-in.

  • Plans: Auth0 extension (enterprise-oriented); more setup than Identity.
  • Logins: one (federated SSO).
  • Per-user identity: full, from the corporate directory; supports auto-provisioning.
  • Tradeoffs: more moving parts than Identity; requires Auth0 configuration. This is the path when invite-only Identity won't scale. Configured via the Netlify Auth0 extension — see the Netlify docs setup guide for Auth0.

Option C — Basic Password Protection + Netlify Identity

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 74 lines · 1,237 tokens per session scan A d599cb678694

Subscribe to this mod's changes

netlify-access-control-two-layer-pattern is a cursor rule published in the GitHub repository netlify/context-and-tools (36 stars, last pushed 5d ago), licensed MIT. It adds 24 tokens to every session and 1,237 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.