mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
create-pull-request/patch
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
477e2c136f |
[FE-5109] (part 6) chore(studio): remove next/router shims, aliases, and test mocks (#54058)
Part 6 (final) of a 6-PR stack migrating all `next/router` and `next/compat/router` imports in `apps/studio` onto TanStack Router hooks and removing the router shims. | Part | PR | Scope | | --- | --- | --- | | 1 | #54053 | Core navigation helpers, `hooks/**`, `lib/**`, `data/prefetchers/**` | | 2 | #54054 | `components/ui/**` | | 3 | #54055 | `components/layouts/**` and `state/tabs.tsx` | | 4 | #54056 | Database, Branching, Compute, Edge Functions, Explorer, SQL Editor, Storage, Table Editor | | 5 | #54057 | Remaining `components/interfaces/**` and `QueryInsightsTable` router events | | **6** | **#54058 ← this PR** | **Remove `next/router` & `next/compat/router` shims, `_router-events.ts`, Vite aliases, and test mocks** | Now that no files in `apps/studio` (or `packages/**`) import `next/router` or `next/compat/router`, deletes the router shims, `_router-events.ts`, their Vite aliases, and the obsolete router test mocks. `RouteValidationWrapper` is intentionally left for FE-3107. **Removed:** - `apps/studio/compat/next/router.ts`, `apps/studio/compat/next/compat/router.ts`, and `apps/studio/compat/next/_router-events.ts` - `'next/router'` and `'next/compat/router'` entries from `nextShims` in `apps/studio/vite.config.ts` - Global `vi.mock('next/router', ...)` and `vi.mock('next/compat/router', ...)` in `apps/studio/tests/vitestSetup.ts`, `mockNextRouter` in `apps/studio/tests/lib/route-aware-hooks.ts`, and the unused `vi.mock('next/router')` in `tests/features/logs/LogTable.test.tsx` - Obsolete shim tests and test helpers: `compat/next/router.test.ts`, `compat/next/router-navigation.test.tsx`, `tests/config/router.tsx`, and `tests/config/router.test.tsx` **Changed:** - Simplified `createNavigationHandler` in `apps/studio/lib/navigation.ts` (and `navigation.test.ts`) to accept TanStack's `UseNavigateResult<string>` only, dropping the `NextRouter` union branch - Updated `compat/next/link-basepath-navigation.test.tsx` (renamed from `router-basepath-navigation.test.tsx`), `lib/router-url-shape.test.tsx`, and `tests/lib/route-render.test.tsx` to exercise TanStack Router hooks directly instead of the removed router shim - Cleaned up stale `next/router` comments in `compat/next/link.tsx`, `lib/internal-url.ts`, `router.tsx`, and `tests/lib/route-mock.ts` **Simplified:** - Removed `routerMock` setup from about 19 tests that no longer read it. `next-router-mock` stays for now, because the test `FrameworkProvider` still feeds `useParams` from it. - `AGENTS.md` and the `vite.config.ts` error text now say only `next/link` and `next/script` are shimmed - Renamed `compat/next/router-basepath-navigation.test.tsx` to `link-basepath-navigation.test.tsx`, and removed stale router-shim references from comments Addresses [FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks) ## To test - [ ] Confirm `git grep -E "next/(compat/)?router|_router-events" apps/studio` returns no code or config imports (only the prose guideline in `apps/studio/AGENTS.md`) - [ ] Confirm `pnpm --filter studio run typecheck`, `pnpm --filter studio run lint`, `pnpm --filter studio run build`, Knip, and the full Studio Vitest suite pass - [ ] Spot-check basePath navigation (`next/link` + `navigateToUrl`) and multi-line query param URLs in Studio --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> |
||
|
|
39b359a70e |
chore: keep db partner roles out of picker (#54019)
## Problem Newly added trusted partner roles appear as user selectable / manageable. Resolves DEPR-735. ## Solution Trusted partner roles should not be selectable in temporary access. And should not appear as modifiable in the database roles tab. | Before | After | | --- | --- | | <img width="553" height="398" alt="CleanShot 2026-11-27 at 12 24 43" src="https://github.com/user-attachments/assets/14affc16-2f00-496f-a124-d918acd93bf0" /> | <img width="553" height="363" alt="CleanShot 2026-11-27 at 12 25 00" src="https://github.com/user-attachments/assets/de06002f-d063-453e-a9da-00eee8e0616d" /> | | _This partner role `this_is_a_test` shouldn’t be here._ | _Partner role `this_is_a_test` is no longer in the list of options._ | | <img width="940" height="305" alt="CleanShot 2026-11-30 at 10 34 52" src="https://github.com/user-attachments/assets/bdface9f-b3f4-4620-b567-cba8d829205e" /> | <img width="935" height="299" alt="CleanShot 2026-11-30 at 10 37 40" src="https://github.com/user-attachments/assets/da1abaa3-5a98-4837-9e8f-35be84b6be4c" /> | | _Previous definition._ | _Broadened definition to better encompass roles we generally manage ([context](https://github.com/supabase/supabase/pull/54019#discussion_r4716757425))._ | ## How to test 1. Open the [Studio staging preview](https://studio-staging-git-chore-depr-735-supabase.vercel.app) and select a staging test project. If **Temporary access** is off in **Feature previews**, enable it there. Then go to **Database → Settings → Temporary access** and make sure it is enabled for the test project. 2. Go to **Database → Roles**. Open Chrome DevTools, select **Network**, and reload. Filter for `key=database-roles`. Right-click the matching request and select **Override content**. 3. Append this test role to the roles array. Save the override and reload. ```json { "id": 99999, "name": "this_is_a_test", "isSuperuser": false, "canCreateDb": false, "canCreateRole": false, "inheritRole": true, "canLogin": true, "isReplicationRole": false, "canBypassRls": false, "activeConnections": 0, "connectionLimit": 90, "validUntil": null, "comment": "{\"_supabase\":{\"oauth_app_id\":\"app\"}}", "config": {} } ``` 4. In **Database → Roles**, make sure that `this_is_a_test` appears under **Supabase managed roles** without edit or delete controls. 5. Go to **Database → Settings → Temporary access**, select **Add rule**, and open the role picker. The test role should be absent. 6. Set the test role's `comment` to `null` in the override and reload. Open **Add rule** again and make sure that the role is now selectable. Close the form without saving and remove the override. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com> |
||
|
|
5ff6930c2a |
feat(studio): send role passwords as precomputed SCRAM-SHA-256 verifiers (#52544)
## What kind of change does this PR introduce? Feature. ## What is the current behavior? Role passwords are sent as plaintext in the SQL (`create role ... password '...'` and `alter role ... password '...'`), so they can end up in Postgres logs. ## What is the new behavior? ASCII role passwords are hashed in the browser with Web Crypto and sent as a precomputed `SCRAM-SHA-256$...` verifier. Postgres stores a verifier as given, so the plaintext no longer appears in the SQL or the server logs. This applies to every flow that sets a role password, because they all go through the role create and update mutations. Non-ASCII passwords are still sent as plaintext. Postgres normalizes passwords with SASLprep before hashing, and the browser code doesn't apply it, so a verifier built from the raw text could stop the role from logging in. For ASCII, SASLprep changes nothing, so the verifier always matches. The `saslprep` package can't be used here because it reads its table with `fs.readFileSync` at import time. Covering non-ASCII passwords is a follow-up, most likely a server-side API. Studio also falls back to plaintext when `crypto.subtle` isn't available, which browsers only expose in secure contexts. This keeps setting a password working on self-hosted Studio served over plain HTTP. ## Known limitations - The verifier is built with 4096 iterations, the Postgres default. If a project sets `scram_iterations` higher, these roles keep 4096, because Postgres stores a supplied verifier as given. Reading the setting first needs an extra query and a grant for it, so it's left for the follow-up below. - Non-ASCII passwords, and Studio over plain HTTP, still send plaintext. - The follow-up is a server-side path that sets the password without it going through the SQL, which would honor the server's own settings and cover these cases. A verifier isn't secret (it can be attacked offline), but it is a clear improvement over plaintext. ## Testing - Unit tests compare the helper with an independent `node:crypto` implementation, and check that ASCII passwords become verifiers and non-ASCII passwords pass through unchanged. - I also checked against a real Postgres: roles given these verifiers log in with the plaintext password and reject a wrong one. - The `CreateRolePanel` test now expects a verifier and no plaintext in the SQL. Resolves FE-4822. |
||
|
|
1e94d386a4 |
feat(studio): add a reset password action for custom roles (#52506)
## What kind of change does this PR introduce? Feature. ## What is the current behavior? The Dashboard only offers a reset password action for the `postgres` role (Database Settings). To change the password of a custom role, users have to run `alter role ... password` in the SQL editor. ## What is the new behavior? Each role row in Database > Roles has a "Reset password" item in its actions menu. It opens a dialog with a warning that anything using the old password will be disconnected, and the shared password field (generate and copy). The password is required in this dialog. - The item is disabled for system roles, and for roles that can't log in, with a tooltip explaining why. - It uses the existing role update mutation, so no platform endpoint is involved. - `RolePasswordField` gains `isOptional` and `layout` props so the dialog can reuse it. <img width="271" height="174" alt="Screenshot 2026-11-02 at 11 11 33" src="https://github.com/user-attachments/assets/36f05fa0-e95c-440c-b6bb-4fadb466c2f6" /> <img width="543" height="414" alt="Screenshot 2026-11-02 at 11 11 17" src="https://github.com/user-attachments/assets/87ba4f50-1315-4e07-b390-9c5b6beba129" /> ## Testing New `RoleRow` component tests cover the item being available for a custom role that can log in, disabled for system roles and roles that can't log in, the required-password validation, and a successful reset. Resolves FE-4813. |
||
|
|
5bb549efae |
feat(studio): allow setting a password when enabling login on an existing role (#52505)
## What kind of change does this PR introduce? Feature. ## What is the current behavior? Turning on "User can login" for an existing role that couldn't log in gives no way to set a password. Users have to run `alter role ... password` in the SQL editor. ## What is the new behavior? In Database > Roles, turning on "User can login" for a role that couldn't log in now shows the same optional password field as the create panel, including the generate and copy actions. - The field only shows for roles that don't currently have login. Roles that can already log in don't get one. - The password is sent only when login is gained in that save and the field isn't empty. An empty field turns on login without a password, as in create mode. - The password is kept out of the "changed fields" diff, so unrelated edits never send `password ''`. - The password field is extracted from the create panel into a shared `RolePasswordField`, which also owns the "Password generated" announcement state. Follow-up to #52463. Changing the password of a role that can already log in is tracked separately and is the next PR in this stack. <img width="840" height="655" alt="Screenshot 2026-10-29 at 15 47 33" src="https://github.com/user-attachments/assets/8bb52e86-7b1e-4911-b625-2532fb7dfa25" /> ## Testing - New `RoleRow` component tests cover the field's visibility, sending the password, and omitting it when empty or for roles that already have login. - Existing `CreateRolePanel` tests still pass. Part of FE-4763. |