Skip to content
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

Bug fix #134

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions supabase/migrations/20240819181951_stripeWrapperKeys.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE SERVER stripe_server FOREIGN DATA WRAPPER stripe_wrapper OPTIONS (api_key_id 'placeholder');

CREATE PROCEDURE install_stripe_secret_reference() AS $$
DECLARE
vault_key_id TEXT;
BEGIN
SELECT key_id::TEXT FROM vault.secrets WHERE name='stripe' INTO vault_key_id;
IF vault_key_id IS NOT NULL THEN
EXECUTE 'ALTER SERVER stripe_server OPTIONS (SET api_key_id ' || quote_literal(vault_key_id) || ')';
END IF;
END
$$ LANGUAGE PLPGSQL;
COMMENT ON PROCEDURE install_stripe_secret_reference() IS 'Look up the Stripe key_id from the vault and set it in the server wrapper';

REVOKE ALL ON PROCEDURE install_stripe_secret_reference FROM PUBLIC,authenticated,anon;

CALL install_stripe_secret_reference();

create schema stripe;

create foreign table stripe.prices (
id text,
active bool,
currency text,
product text,
unit_amount bigint,
type text,
created timestamp,
attrs jsonb
)
server stripe_server
options (
object 'prices'
);
Loading