-
-
Notifications
You must be signed in to change notification settings - Fork 122
fix(api): allow scoped keys past cli warnings #2075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
riderx
wants to merge
3
commits into
main
Choose a base branch
from
codex/fix-cli-warning-scoped-api-keys
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+164
−0
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
supabase/migrations/20260507171200_skip_cli_warning_read_fatal_for_scoped_keys.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| CREATE OR REPLACE FUNCTION "public"."get_organization_cli_warnings"("orgid" uuid, "cli_version" text) | ||
| RETURNS jsonb[] | ||
| LANGUAGE plpgsql | ||
| SECURITY DEFINER | ||
| SET search_path = '' | ||
| AS $$ | ||
| DECLARE | ||
| messages jsonb[] := ARRAY[]::jsonb[]; | ||
| has_read_access boolean; | ||
| BEGIN | ||
| PERFORM cli_version; | ||
|
|
||
| SELECT public.check_min_rights( | ||
| 'read'::public.user_min_right, | ||
| public.get_identity_apikey_only('{write,all,upload,read}'::public.key_mode[]), | ||
| orgid, | ||
| NULL::varchar, | ||
| NULL::bigint | ||
| ) | ||
| INTO has_read_access; | ||
|
|
||
| IF NOT COALESCE(has_read_access, false) THEN | ||
| -- Upload performs app-scoped permission and plan checks after this RPC. | ||
| -- App-scoped API keys may legitimately upload without org-level read access, | ||
| -- so skip org warnings instead of blocking the upload here. | ||
| RETURN messages; | ||
|
riderx marked this conversation as resolved.
|
||
| END IF; | ||
|
|
||
| IF ( | ||
| public.is_paying_and_good_plan_org_action(orgid, ARRAY['mau']::public.action_type[]) = true | ||
| AND public.is_paying_and_good_plan_org_action(orgid, ARRAY['bandwidth']::public.action_type[]) = true | ||
| AND public.is_paying_and_good_plan_org_action(orgid, ARRAY['storage']::public.action_type[]) = false | ||
| ) THEN | ||
| messages := array_append(messages, jsonb_build_object( | ||
| 'message', | ||
| 'You have exceeded your storage limit.\nUpload will fail, but you can still download your data.\nMAU and bandwidth limits are not exceeded.\nIn order to upload your plan, please upgrade your plan here: https://console.capgo.app/settings/plans.', | ||
| 'fatal', | ||
| true | ||
| )); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| END IF; | ||
|
|
||
| RETURN messages; | ||
| END; | ||
| $$; | ||
|
|
||
| ALTER FUNCTION "public"."get_organization_cli_warnings"("orgid" uuid, "cli_version" text) OWNER TO "postgres"; | ||
| REVOKE ALL ON FUNCTION "public"."get_organization_cli_warnings"("orgid" uuid, "cli_version" text) FROM PUBLIC; | ||
| GRANT ALL ON FUNCTION "public"."get_organization_cli_warnings"("orgid" uuid, "cli_version" text) TO "anon"; | ||
| GRANT ALL ON FUNCTION "public"."get_organization_cli_warnings"("orgid" uuid, "cli_version" text) TO "authenticated"; | ||
| GRANT ALL ON FUNCTION "public"."get_organization_cli_warnings"("orgid" uuid, "cli_version" text) TO "service_role"; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.