From ab6d5cefbea1e8ddf41f385dd85918f651958287 Mon Sep 17 00:00:00 2001
From: benj <benj@rse8.com>
Date: Mon, 19 Jun 2023 17:18:21 -0700
Subject: hack to allow impersonator to impersonate target

---
 crates/secd/store/pg/sql/find_impersonator.sql | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 crates/secd/store/pg/sql/find_impersonator.sql

(limited to 'crates/secd/store/pg/sql/find_impersonator.sql')

diff --git a/crates/secd/store/pg/sql/find_impersonator.sql b/crates/secd/store/pg/sql/find_impersonator.sql
new file mode 100644
index 0000000..e544598
--- /dev/null
+++ b/crates/secd/store/pg/sql/find_impersonator.sql
@@ -0,0 +1,10 @@
+select i2.identity_public_id as impersonator_public_id
+       , i3.identity_public_id as target_public_id
+       , i.created_at
+from secd.impersonator i
+join secd.identity i2 on i.impersonator_id = i2.identity_id
+join secd.identity i3 on i.target_id = i3.identity_id
+join secd.credential c using (credential_id)
+where (($1::uuid is null) or (i2.identity_public_id = $1))
+and (($2::uuid is null) or (i3.identity_public_id = $2))
+and c.revoked_at > $3;
-- 
cgit v1.2.3

