Skip to content

Project create security section updates#42021

Merged
SaxonF merged 8 commits intomasterfrom
chore/project-create-security
Feb 2, 2026
Merged

Project create security section updates#42021
SaxonF merged 8 commits intomasterfrom
chore/project-create-security

Conversation

@SaxonF
Copy link
Copy Markdown
Contributor

@SaxonF SaxonF commented Jan 21, 2026

image

This reworks the security section within our project creation form to expose two options.

1/ Enable or disable Data API which is essentially the same as we had previously, just reframed
2/ Enable auto RLS which creates an event trigger that enables RLS on all tables created via public schema. This is the same as what we do via the RLS banner in authentication pages.

Note that this also removes the option to disable Data API on public schema and move to dedicated schema. The user can still do this post project creation . Assumption is this is rarely changed on project creation and adds complexity.

To test:

  1. Create a new project
  2. Enable Data API and enable RLS setting
  3. After project creation, go to triggers -> event tab -> notice enable rls trigger
  4. Create project and disable Data API
  5. After project creation , go to settings/api and make sure data api is disabled

Summary by CodeRabbit

  • New Features

    • Added an optional automatic Row-Level Security (RLS) event trigger option in project creation (toggleable via experiment).
  • Improvements

    • Security panel simplified to checkbox-based controls for Data API and RLS.
    • Project creation form now includes the enableRlsEventTrigger flag and applies related setup when enabled.
    • Telemetry records RLS experiment exposure, variant, and whether the RLS trigger was enabled.
    • Free-project messaging updated to consider user limits.

✏️ Tip: You can customize this high-level summary in your review settings.

@SaxonF SaxonF requested a review from a team as a code owner January 21, 2026 03:04
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Feb 2, 2026 4:26am
studio-staging Ready Ready Preview, Comment Feb 2, 2026 4:26am
6 Skipped Deployments
Project Deployment Actions Updated (UTC)
cms Ignored Ignored Feb 2, 2026 4:26am
studio Ignored Ignored Feb 2, 2026 4:26am
design-system Skipped Skipped Feb 2, 2026 4:26am
docs Skipped Skipped Feb 2, 2026 4:26am
ui-library Skipped Skipped Feb 2, 2026 4:26am
zone-www-dot-com Skipped Skipped Feb 2, 2026 4:26am

Request Review

@supabase
Copy link
Copy Markdown

supabase Bot commented Jan 21, 2026

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@SaxonF SaxonF changed the title security section project create Project create security section updates Jan 21, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

Walkthrough

Replaces useApiSchema with enableRlsEventTrigger in the project creation form, refactors SecurityOptions UI to panel/checkbox layout with a feature-flagged RLS checkbox, injects RLS SQL into the submit payload when enabled, adds telemetry for RLS experiment exposure, and uses profile data to gate free-project messaging.

Changes

Cohort / File(s) Summary
Form Schema
apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts
Removed useApiSchema: z.boolean() and added enableRlsEventTrigger: z.boolean() to the exported FormSchema.
Security Options Component
apps/studio/components/interfaces/ProjectCreation/SecurityOptions.tsx
Removed collapsible prop and radio-group UI; replaced with static panel layout and checkbox controls for Data API. Added feature-flag-driven conditional rendering for the enableRlsEventTrigger UI. Updated onChange handling and admonition placement.
Project Creation Page
apps/studio/pages/new/[slug].tsx
Replaced useApiSchema with enableRlsEventTrigger in defaults and submit payload. When enabled, adds dbSql: AUTO_ENABLE_RLS_EVENT_TRIGGER_SQL to creation payload. Tracks RLS experiment exposure/variant via telemetry and uses useProfile to gate free-project info.
Telemetry Constants
packages/common/telemetry-constants.ts
Added ProjectCreationRlsOptionExperimentExposedEvent; extended ProjectCreationSimpleVersionSubmittedEvent.properties with enableRlsEventTrigger?: boolean and `rlsOptionVariant?: 'control'

Sequence Diagram(s)

sequenceDiagram
  participant User as User (browser)
  participant UI as Project Creation Page
  participant API as Project Creation API
  participant DB as Database

  User->>UI: fill & submit form (dataApi, enableRlsEventTrigger, ...)
  UI->>API: POST /createProject { ..., dataApi, enableRlsEventTrigger, dataApiUseApiSchema:false, dbSql? }
  alt enableRlsEventTrigger == true
    API->>DB: execute AUTO_ENABLE_RLS_EVENT_TRIGGER_SQL
    DB-->>API: success
  end
  API-->>UI: project created response
  UI-->>User: show success / next steps
Loading

Possibly related PRs

Suggested reviewers

  • alaister
  • pamelachia
  • awaseem
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: reworking the security section in project creation to expose Data API and auto RLS options.
Description check ✅ Passed The description addresses most template sections with clear context, but is missing explicit confirmation of reading CONTRIBUTING.md and lacks categorization of the change type.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 21, 2026

Coverage Status

coverage: 66.134%. remained the same
when pulling 8297dab on chore/project-create-security
into 842722d on master.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@apps/studio/components/interfaces/ProjectCreation/SecurityOptions.tsx`:
- Around line 46-52: The external Link in SecurityOptions.tsx using
target="_blank" (the Link with href
"https://supabase.com/docs/reference/javascript/introduction" and className
"text-link") is missing a rel attribute; add rel="noopener noreferrer" to that
Link element to prevent reverse-tabnabbing and ensure safe external navigation.
- Around line 85-90: The Admonition currently reads form.getValues('dataApi'),
which does not trigger re-renders; replace that usage by subscribing to the form
field with useWatch_Shadcn_ so the warning is reactive: import and call
useWatch_Shadcn_ to watch the 'dataApi' field (e.g. const dataApi =
useWatch_Shadcn_({ control: form.control, name: 'dataApi' })), then use that
dataApi boolean in the conditional that renders the Admonition instead of
form.getValues('dataApi'); ensure the import for useWatch_Shadcn_ is added if
missing and remove the stale getValues() usage.

Comment on lines +46 to +52
<Link
href="https://supabase.com/docs/reference/javascript/introduction"
target="_blank"
className="text-link"
>
supabase-js
</Link>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add rel on external target="_blank" link.
Prevents reverse‑tabnabbing when opening external docs.

🔐 Proposed fix
                     <Link
                       href="https://supabase.com/docs/reference/javascript/introduction"
                       target="_blank"
+                      rel="noreferrer noopener"
                       className="text-link"
                     >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Link
href="https://supabase.com/docs/reference/javascript/introduction"
target="_blank"
className="text-link"
>
supabase-js
</Link>
<Link
href="https://supabase.com/docs/reference/javascript/introduction"
target="_blank"
rel="noreferrer noopener"
className="text-link"
>
supabase-js
</Link>
🤖 Prompt for AI Agents
In `@apps/studio/components/interfaces/ProjectCreation/SecurityOptions.tsx` around
lines 46 - 52, The external Link in SecurityOptions.tsx using target="_blank"
(the Link with href
"https://supabase.com/docs/reference/javascript/introduction" and className
"text-link") is missing a rel attribute; add rel="noopener noreferrer" to that
Link element to prevent reverse-tabnabbing and ensure safe external navigation.

Comment thread apps/studio/components/interfaces/ProjectCreation/SecurityOptions.tsx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 21, 2026

🎭 Playwright Test Results

passed  84 passed
flaky  2 flaky
skipped  4 skipped

Details

stats  90 tests across 14 suites
duration  9 minutes, 49 seconds
commit  c190996

Flaky tests

Features › sql-editor.spec.ts › SQL Editor › should check if SQL editor is working as expected
Features › table-editor.spec.ts › table editor › can create and remove foreign key with column selection

Skipped tests

Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

postgresEngine: useOrioleDb ? availableOrioleVersion?.postgres_engine : postgresEngine,
releaseChannel: useOrioleDb ? availableOrioleVersion?.release_channel : releaseChannel,
...(smartRegionEnabled ? { regionSelection: selectedRegion } : { dbRegion }),
...(enableRlsEventTrigger ? { dbSql: AUTO_ENABLE_RLS_EVENT_TRIGGER_SQL } : {}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for future: we should only use this for testing purposes because it prevents warm project pool transfer, which increases project startup time for users

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a platform PR to fix this

@SaxonF SaxonF requested a review from a team as a code owner January 23, 2026 02:51
@SaxonF SaxonF added the autofix label Jan 23, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/studio/pages/new/`[slug].tsx:
- Around line 230-235: The current match allows undefined emails to compare
equal when profile hasn't loaded; update the logic around userPrimaryEmail and
isUserAtFreeProjectLimit so comparisons only run when userPrimaryEmail is
defined: ensure userPrimaryEmail is checked truthy before using it in
membersExceededLimit.some and/or filter members to only those with a truthy
primary_email (use member.primary_email) in isUserAtFreeProjectLimit, and make
shouldShowFreeProjectInfo depend on the presence of userPrimaryEmail as well;
reference the variables userPrimaryEmail, isUserAtFreeProjectLimit,
membersExceededLimit and profile to locate and change the comparison guard.
♻️ Duplicate comments (2)
apps/studio/components/interfaces/ProjectCreation/SecurityOptions.tsx (2)

51-56: Add rel on external target="_blank" link.
Missing rel="noreferrer noopener" exposes reverse‑tabnabbing risk.

🔐 Proposed fix
                     <Link
                       href="https://supabase.com/docs/reference/javascript/introduction"
                       target="_blank"
+                      rel="noreferrer noopener"
                       className="text-link"
                     >

92-96: Make the Data API warning reactive to checkbox state.
getValues() won’t trigger re-renders, so the Admonition can remain stale.

🔧 Proposed fix
 import {
   Checkbox_Shadcn_,
   FormControl_Shadcn_,
   FormDescription_Shadcn_,
   FormField_Shadcn_,
   FormItem_Shadcn_,
   FormLabel_Shadcn_,
+  useWatch_Shadcn_,
 } from 'ui'
@@
 export const SecurityOptions = ({ form, layout = 'horizontal' }: SecurityOptionsProps) => {
   const shouldShowEnableRlsEventTrigger = usePHFlag<string>(
     'projectCreationEnableRlsEventTrigger'
   )
+  const isDataApiEnabled = useWatch_Shadcn_({ control: form.control, name: 'dataApi' })
@@
-          {!form.getValues('dataApi') && (
+          {!isDataApiEnabled && (
             <Admonition type="warning" title="Data API will effectively be disabled">
               You will not be able to query or mutate data via Supabase client libraries like
               supabase-js.
             </Admonition>
           )}

Comment thread apps/studio/pages/new/[slug].tsx
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/studio/pages/new/`[slug].tsx:
- Around line 75-78: Remove the duplicated feature-flag computation by passing
the already-computed rlsExperimentVariant-derived boolean into the
SecurityOptions component: use the existing usePHFlag call that defines
rlsExperimentVariant and the derived shouldShowEnableRlsEventTrigger variable,
then supply shouldShowEnableRlsEventTrigger as a prop to <SecurityOptions ... />
and remove the internal recomputation inside the SecurityOptions component so it
consumes the prop instead of calling usePHFlag itself.

Comment on lines +75 to +78
const rlsExperimentVariant = usePHFlag<'control' | 'test' | false | undefined>(
'projectCreationEnableRlsEventTrigger'
)
const shouldShowEnableRlsEventTrigger = rlsExperimentVariant === 'test'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Search for shouldShowEnableRlsEventTrigger usage in the new.tsx file
rg -n 'shouldShowEnableRlsEventTrigger' apps/studio/pages/new/

# Also check the SecurityOptions component to see what props it accepts
fd -t f 'SecurityOptions' apps/studio/ --exec head -50 {}

# If SecurityOptions is exported from another file, find it
rg -n 'export.*SecurityOptions' apps/studio/

Repository: supabase/supabase

Length of output: 2204


🏁 Script executed:

# Get more context from the pages/new/[slug].tsx file around line 75-78 and where SecurityOptions is used
sed -n '70,120p' apps/studio/pages/new/[slug].tsx | cat -n

# Check if shouldShowEnableRlsEventTrigger is used anywhere in pages/new/[slug].tsx
rg -A 20 -B 5 'const shouldShowEnableRlsEventTrigger' apps/studio/pages/new/[slug].tsx

Repository: supabase/supabase

Length of output: 3871


🏁 Script executed:

# Search for where SecurityOptions is used in pages/new/[slug].tsx
rg -n 'SecurityOptions' apps/studio/pages/new/[slug].tsx | head -20

# Get the full context of the pages/new/[slug].tsx file around where SecurityOptions is rendered
rg -B 5 -A 10 '<SecurityOptions' apps/studio/pages/new/[slug].tsx

Repository: supabase/supabase

Length of output: 845


Remove unused shouldShowEnableRlsEventTrigger variable or pass it to SecurityOptions.

The variable shouldShowEnableRlsEventTrigger is defined on line 78 but never used in this file. Currently, the SecurityOptions component computes its own shouldShowEnableRlsEventTrigger variable independently. To avoid duplicate computation of the flag, pass this variable to the SecurityOptions component as a prop.

🤖 Prompt for AI Agents
In `@apps/studio/pages/new/`[slug].tsx around lines 75 - 78, Remove the duplicated
feature-flag computation by passing the already-computed
rlsExperimentVariant-derived boolean into the SecurityOptions component: use the
existing usePHFlag call that defines rlsExperimentVariant and the derived
shouldShowEnableRlsEventTrigger variable, then supply
shouldShowEnableRlsEventTrigger as a prop to <SecurityOptions ... /> and remove
the internal recomputation inside the SecurityOptions component so it consumes
the prop instead of calling usePHFlag itself.

@seanoliver seanoliver force-pushed the chore/project-create-security branch from 9d1d3a5 to 8297dab Compare January 23, 2026 20:17
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/studio/pages/new/[slug].tsx (1)

1-63: Prettier check failed for this file.
Please run Prettier (e.g., prettier --write) to resolve the CI formatting error.

♻️ Duplicate comments (1)
apps/studio/components/interfaces/ProjectCreation/SecurityOptions.tsx (1)

54-60: Add rel to the external target="_blank" link.
Prevents reverse‑tabnabbing.

🔐 Proposed fix
                     <Link
                       href="https://supabase.com/docs/reference/javascript/introduction"
                       target="_blank"
+                      rel="noreferrer noopener"
                       className="text-link"
                     >

Copy link
Copy Markdown
Contributor

@seanoliver seanoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM! I added a few tweaks in this commit: 9d1d3a5

  • Switched the feature flag to a multivariate string response instead of boolean (this allows us to measure the experiment in PostHog)
  • Added the useWatch_Shadcn_ hook so the form is reactive to the box being checked
  • Added an exposure event that only fires if the user is bucketed into control or test (meaning it won't fire for users who aren't currently bucketed or before the experiment has officially launched)

Tested that the events are logging correctly and the UI is updating appropriately in local dev. Experiment is ramped to 100% in staging so you should be able to test this on the staging site as well.

@SaxonF SaxonF merged commit 0760733 into master Feb 2, 2026
24 checks passed
@SaxonF SaxonF deleted the chore/project-create-security branch February 2, 2026 05:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

Braintrust eval report

Assistant (master-1770011493)

Score Average Improvements Regressions
Completeness 91.7% (+0pp) - -
Conciseness 4.2% (+4pp) 1 🟢 -
Goal Completion 91.7% (-4pp) - 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+17pp) 1 🟢 -
Tool Usage 100% (+0pp) - -
Docs Faithfulness 58.3% (-8pp) - 1 🔴
Correctness 100% (+0pp) - -
URL Validity 100% (+0pp) - -
Time_to_first_token 0.22tok (+0.03tok) 3 🟢 9 🔴
Llm_calls 8.5 (+0) 2 🟢 2 🔴
Tool_calls 3.42 (+0.25) 4 🟢 1 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 99156.33tok (+3903.75tok) 6 🟢 6 🔴
Prompt_cached_tokens 53994.67tok (-3797.33tok) 5 🟢 7 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 5124.83tok (-300.92tok) 7 🟢 5 🔴
Completion_reasoning_tokens 3818.67tok (-202.67tok) 6 🟢 5 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 104281.17tok (+3602.83tok) 7 🟢 5 🔴
Estimated_cost 0.02$ (+0$) 6 🟢 6 🔴
Duration 46.76s (+5.57s) 3 🟢 9 🔴
Llm_duration 92.46s (+13.03s) 3 🟢 9 🔴

awaseem pushed a commit that referenced this pull request Feb 3, 2026
<img width="1196" height="427" alt="image"
src="https://github.com/user-attachments/assets/6784b5e9-99c8-4fc9-b9f5-49672ba6e768"
/>

This reworks the security section within our project creation form to
expose two options.

1/ Enable or disable Data API which is essentially the same as we had
previously, just reframed
2/ Enable auto RLS which creates an event trigger that enables RLS on
all tables created via public schema. This is the same as what we do via
the RLS banner in authentication pages.

Note that this also removes the option to disable Data API on public
schema and move to dedicated schema. The user can still do this post
project creation . Assumption is this is rarely changed on project
creation and adds complexity.

To test:
1. Create a new project
2. Enable Data API and enable RLS setting
3. After project creation, go to triggers -> event tab -> notice enable
rls trigger
4. Create project and disable Data API
5. After project creation , go to settings/api and make sure data api is
disabled

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added an optional automatic Row-Level Security (RLS) event trigger
option in project creation (toggleable via experiment).

* **Improvements**
* Security panel simplified to checkbox-based controls for Data API and
RLS.
* Project creation form now includes the enableRlsEventTrigger flag and
applies related setup when enabled.
* Telemetry records RLS experiment exposure, variant, and whether the
RLS trigger was enabled.
  * Free-project messaging updated to consider user limits.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
Co-authored-by: Sean Oliver <882952+seanoliver@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants