Repository navigation
Expand file tree
/
Copy pathprovisionerkeys.sql
More file actions
82 lines (75 loc) · 1.57 KB
/
Copy pathprovisionerkeys.sql
File metadata and controls
82 lines (75 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- name: InsertProvisionerKey :one
INSERT INTO
provisioner_keys (
id,
created_at,
organization_id,
name,
hashed_secret,
tags
)
VALUES
($1, $2, $3, lower(@name), $4, $5) RETURNING *;
-- name: GetProvisionerKeyByID :one
SELECT
*
FROM
provisioner_keys
WHERE
id = $1;
-- name: LockProvisionerKeyByIDForShare :one
-- Locks the provisioner key row with FOR KEY SHARE for the remainder of the
-- current transaction. FOR KEY SHARE conflicts with DELETE, so while the lock
-- is held the key cannot be deleted, and a committed deletion is observed as
-- no rows by later calls.
SELECT
id
FROM
provisioner_keys
WHERE
id = $1
FOR KEY SHARE;
-- name: GetProvisionerKeyByHashedSecret :one
SELECT
*
FROM
provisioner_keys
WHERE
hashed_secret = $1;
-- name: GetProvisionerKeyByName :one
SELECT
*
FROM
provisioner_keys
WHERE
organization_id = $1
AND
lower(name) = lower(@name);
-- name: ListProvisionerKeysByOrganizationExcludeReserved :many
SELECT
*
FROM
provisioner_keys
WHERE
organization_id = $1
AND
-- exclude reserved built-in key
id != '00000000-0000-0000-0000-000000000001'::uuid
AND
-- exclude reserved user-auth key
id != '00000000-0000-0000-0000-000000000002'::uuid
AND
-- exclude reserved psk key
id != '00000000-0000-0000-0000-000000000003'::uuid;
-- name: ListProvisionerKeysByOrganization :many
SELECT
*
FROM
provisioner_keys
WHERE
organization_id = $1;
-- name: DeleteProvisionerKey :exec
DELETE FROM
provisioner_keys
WHERE
id = $1;