From eb92f823c31a5e702af7005231f0d6915aad3342 Mon Sep 17 00:00:00 2001 From: benj Date: Mon, 24 Apr 2023 13:24:45 -0700 Subject: email templates, sendgrid, creds, and some experimental things Started playing with namespace configs and integrating with zanzibar impls. Still lot's of experimenting and dead code going on. --- crates/secd/store/pg/sql/find_credential.sql | 12 ++++++++++++ crates/secd/store/pg/sql/write_credential.sql | 19 +++++++++++++++++++ crates/secd/store/pg/sql/write_identity.sql | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 crates/secd/store/pg/sql/find_credential.sql create mode 100644 crates/secd/store/pg/sql/write_credential.sql (limited to 'crates/secd/store/pg/sql') diff --git a/crates/secd/store/pg/sql/find_credential.sql b/crates/secd/store/pg/sql/find_credential.sql new file mode 100644 index 0000000..e30c0ea --- /dev/null +++ b/crates/secd/store/pg/sql/find_credential.sql @@ -0,0 +1,12 @@ +select c.credential_public_id + , i.identity_public_id + , c.data::text + , c.created_at + , c.revoked_at + , c.deleted_at +from secd.credential c +join secd.identity i using (identity_id) +where (($1::uuid is null) or (c.credential_public_id = $1)) +and (($2::uuid is null) or (i.identity_public_id = $2)) +and (($3::text is null) or (c.type = $3)) +and (($3::text is null or $4::text is null) or (c.data->$3->>'key' = $4)) diff --git a/crates/secd/store/pg/sql/write_credential.sql b/crates/secd/store/pg/sql/write_credential.sql new file mode 100644 index 0000000..17e03a2 --- /dev/null +++ b/crates/secd/store/pg/sql/write_credential.sql @@ -0,0 +1,19 @@ +insert into secd.credential ( + credential_public_id + , identity_id + , partial_key + , type + , data + , created_at + , revoked_at + , deleted_at +) values ( + $1 + , (select identity_id from secd.identity where identity_public_id = $2) + , $3 + , $4 + , $5::jsonb + , $6 + , $7 + , $8 +); diff --git a/crates/secd/store/pg/sql/write_identity.sql b/crates/secd/store/pg/sql/write_identity.sql index 67662a6..4b2745b 100644 --- a/crates/secd/store/pg/sql/write_identity.sql +++ b/crates/secd/store/pg/sql/write_identity.sql @@ -5,7 +5,7 @@ insert into secd.identity ( , updated_at , deleted_at ) values ( - $1, $2::jsonb, $3, $4, $5 + $1, $2, $3, $4, $5 ) on conflict (identity_public_id) do update set data = excluded.data , updated_at = excluded.updated_at -- cgit v1.2.3