-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathvault.postgres.txt
46 lines (37 loc) · 2.2 KB
/
vault.postgres.txt
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
┏━━━━━━━━━━━┓
┃ VAULT ┃
┗━━━━━━━━━━━┛
VERSION ==> #0.2.9
supabase_vault #Postgres EXTENSION
#Uses pgsodium
vault #SCHEMA
vault.create_secret('VAL'[, 'VAR'
[, 'DESCRIPTION'
[, KEY_ID_UUID]]])->UUID #Insert into vault.secrets.*
vault.update_secret(UUID, 'VAL'
[, 'VAR' [, 'DESCRIPTION'
[, KEY_ID_UUID]]]) #update vault.secrets.*
vault #TFUNC
.secrets_encrypt_secret_secret #On `before insert or update` and `for each row`
(...) #Encrypts a COL on insert|update
vault.secrets #TABLE to insert secret values
vault.secrets.id #UUID (def: random)
vault.secrets.name #'VAR'
vault.secrets.secret #Encrypted 'VAL', base64'd
#Encrypted with key_id, but uses id + description + created_at + updated_at + nonce too
# - i.e. those COLs integrity is checked
# - list of COLs is stored as a SECURITY_LABEL on the TABLE
vault.secrets.description #STR (def: '')
vault.secrets.key_id #Secret pgsodium.key.id, used to encrypt|decrypt
#The actual key is only available in SQL FUNC, not as data
# - vault.secrets.* can be public
# - vault.decrypted_secrets.* is private
# - anyone who can call pgsodium SQL FUNC can decrypt
vault.secrets.nonce #BYTEA (def: random). Public nonce
vault.secrets.created_at
|updated_at #TIMESTAMPTZ (def: auto)
vault.decrypted_secrets #VIEW on vault.secrets.*
vault.decrypted_secrets.* #Like vault.secrets.*
vault.decrypted_secrets
.decrypted_secret #'VAL', using pgsodium on vault.secrets.*
LOGGING ==> #Requires setting ZSCONF.log_statement 'none' to prevent leaks