Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Vault and TCE docs.

Michel Pelletier405fdac633e8
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index 78292feff7e..2797c867e85 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -358,6 +358,8 @@ export const database = {
{ name: 'Database Webhooks', url: '/guides/database/webhooks' },
{ name: 'Full Text Search', url: '/guides/database/full-text-search' },
{ name: 'Database Testing', url: '/guides/database/testing' },
+ { name: 'Vault', url: '/guides/database/vault' },
+ { name: 'Column Encryption', url: '/guides/database/column-encryption' },
{
name: 'Extensions',
url: undefined,
diff --git a/apps/docs/pages/guides/database/column-encryption.mdx b/apps/docs/pages/guides/database/column-encryption.mdx
new file mode 100644
index 00000000000..1e2ec672df2
--- /dev/null
+++ b/apps/docs/pages/guides/database/column-encryption.mdx
@@ -0,0 +1,267 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'storage',
+ title: 'Storage',
+ description: 'Use Supabase to store and serve files.',
+ sidebar_label: 'Overview',
+ video: 'https://www.youtube.com/v/J9mTPY8rIXE',
+}
+
+Encrypted Columns for Tables
+
+## Transparent Column Encryption (TCE)
+
+Our recent [blog post](/blog/transparent-column-encryption-with-postgres) describes TCE in-depth. TCE is one of the safest ways to encrypt your data so that it doesn't leak into logs and backups, as well as providing your users with row-level authenticated encryption. TCE is the foundational feature of the Vault, but you can use it on your own tables if you choose to if the Vault isn't sufficient for your needs, for example if you have multiple tables that you wish to have encrypted columns. Any Postgres value that can be cast to `text` or `bytea` can use TCE to encrypt the data that is stored to disk.
+
+### Encrypting columns
+
+In the “New Column” flow on the Dashboard, you can select that a `text` or `bytea` column is encrypted, and select an existing key id or create a new one. This is functionally identical to the Vault above, but you can apply it to any of your existing tables. In a sense the Vault is a pre-created table and UI for you to get started quickly storing secrets, and to be a centralized point for “global” secrets management, but your not stuck with just that, you can encrypt multiple columns in multiple tables, how you want to store your secret data can be entirely up to you.
+
+![Encrypting columns](/images/blog/launch-week-6/vault/vault-encrypting-columns.png)
+
+Once you've setup an encrypted column, just insert data into the table like you would any other table. If you put in an email address for example, you will see that what is stored is not an email at all, but an encrypted value.
+
+![Encrypted data](/images/blog/launch-week-6/vault/vault-encrypted-data.png)
+
+Decrypted data can be accessed by a special view that is automatically created whenever you create an encrypted column on a table. This view decrypts the data row-by-row as you access it. By default this view is called `decrypted_<your-table-name>`, so in the example provided, the decryption view for the `profiles` table is `decrypted_profiles`. In addition to the existing `emails` column, there is a new column in the view called `decrypted_emails` that contains the decrypted email value. It's that simple!
+
+### Encrypting Columns From SQL
+
+One of the more common questions we receive at Supabase is “how do I encrypt sensitive data”?
+
+pgsodium's Transparent Column Encryption (TCE) is one of the safest ways, and can be used to encrypt one or more text columns in any number of tables. Using TCE, you can encrypt data so that it doesn't leak into logs as well as providing your users with row-level encryption.
+
+To understand how TCE works, let's first do a deep-dive into an important encryption topic: key derivation.
+
+<div className="bg-gray-300 rounded-lg p-6 italic">
+
+This post is a sneak peek of a big feature we are shipping on LW6. To not miss a thing, get your ticket for [Supabase Launch Week 6!](https://supabase.com/launch-week).
+
+</div>
+
+## How Key Derivation Works
+
+The current state-of-the-art in encryption libraries is [libsodium](https://doc.libsodium.org/).
+
+**libsodium** offers a range of APIs for authenticated secret and public key encryption, key derivation, encrypted streaming, [AEAD](https://en.wikipedia.org/wiki/Authenticated_encryption), various forms of hashing, and much more.
+
+This powerful API is available to PostgreSQL using the [**pgsodium**](https://github.com/michelp/pgsodium) extension. **pgsodium** provides all the functionality of the full **libsodium** API, but previously it required developers to set up database encryption themselves, which remained a challenge even for those familiar with database administration.
+
+To solve this problem, **pgsodium** now has a full key management API, primarily via the table `pgsodium.key` and the `pgsodium.create_key()` function. This key table contains no raw keys, but instead uses libsodium Key IDs to derive keys that are used internally for encryption. A [key derivation function](https://libsodium.gitbook.io/doc/key_derivation) is used with an internal root key that is unavailable to SQL and not stored in the database, but rather managed by you externally using flexible scripts, or by Supabase automatically as part of our service offering.
+
+The simplest way to use **pgsodium** to encrypt and decrypt data is to first create a **Key ID**. Valid Key IDs are stored in pgsodium in a special extension table, and they can be created using the `pgsodium.create_key()` function. This function takes a number of arguments depending on how it's used, but the simplest case is to create a new key with no arguments:
+
+```sql
+select * from pgsodium.create_key();
+-[ RECORD 1 ]---+-------------------------------------
+id | eaa20d8c-c77c-4985-9f73-2a5f5d1f1e6d
+name |
+status | valid
+key_type | aead-det
+key_id | 2
+key_context | \x7067736f6469756d
+created | 2022-11-13 21:19:35.765823+00
+expires |
+associated_data |
+```
+
+This key can now be used with pgsodium encryption functions by its UUID (`eaa20d8c-c77c-4985-9f73-2a5f5d1f1e6d`). For example:
+
+```sql
+select * from pgsodium.crypto_aead_det_encrypt (
+ 'this is the message', -- a message to encrypt
+ 'this is associated data', -- some authenticated associated data
+ 'eaa20d8c-c77c-4985-9f73-2a5f5d1f1e6d'::uuid -- key ID
+);
+```
+
+This produces the following encrypted “ciphertext” using the `aead-det` algorithm from the libsodium [XChaCha20-SIV](https://github.com/jedisct1/libsodium-xchacha20-siv) encryption function.
+
+```
+-[ RECORD 1 ]-----------+---------------------------------------------------------------------------------------------------------
+crypto_aead_det_encrypt | \\x099baa820250d7375ed141f8f1936af384bc229f3de1010a6eff6ffdaf3998baffbae75b5cd83d1c469407ff2d3764a428b742
+```
+
+Now to decrypt the ciphertext, pass it to the decryption function _with the same Key ID_:
+
+```sql
+select *
+from convert_from(pgsodium.crypto_aead_det_decrypt (
+ '\\x099baa820250d7375ed141f8f1936af384bc229f3de1010a6eff6ffdaf3998baffbae75b5cd83d1c469407ff2d3764a428b742',
+ 'this is associated data',
+ 'eaa20d8c-c77c-4985-9f73-2a5f5d1f1e6d'::uuid
+), 'utf8');
+```
+
+Which recovers the original “plaintext” message:
+
+```
+-[ RECORD 1 ]+--------------------
+convert_from | this is the message
+```
+
+In the above example, there is _no raw key_, only a Key ID which is used to derive the key used to encrypt the message and authenticate it with the associated data. In fact, it is impossible for a SQL user to derive the key used above, and if the Key ID is stored, then no encryption keys or decrypted information will leak into backups, disk storage, or the database WAL stream.
+
+## Transparent Column Encryption
+
+As of **pgsodium** 3.0.0 and up, the extension offers a simple and declarative Transparent Column Encryption feature (TCE). This feature is now shipped with all Supabase projects. TCE allows you to specify encrypted columns within a table and generates a new view that “wraps” that table to decrypt the contents.
+
+TCE works using two dynamically generated objects for tables that contain encrypted columns:
+
+- an `INSERT UPDATE` trigger that encrypts data when it is inserted or modified
+- a view that is created to wrap the table to decrypt the data when it is accessed
+
+To “transparently” decrypt the table, access the dynamically generated view _instead of the table_. For every encrypted column in the table, the view will have an additional decrypted column that shows the decrypted result.
+
+It's worth noting at this point that sometimes there is some confusion about handling encrypted data with TCE. The `T` stands for **Transparent** which means, you can always see decrypted data through the view, where the decrypted data can't be see is when stored on disk, or in pg_dumps, backups, WAL streams, etc. This is often called **Encryption At Rest** and is one layer in many that may be used to encrypt and protect your data.
+
+Often Transparent encryption is understood to be “Transparent Disk Encryption” or “Full Disk Encryption”, this is where a drive is encrypted but reading and writing that drive is decrypted. TCE is similar to this, where data on disk is encrypted, but it is more fine grained, only particular columns are encrypted. The data is also encrypted in the sense that the table stored on disk contains encrypted data, without the view or the key, pg_dumps and backups still contain encrypted data, this is not possible with disk-only encryption.
+
+For the moment TCE only works for columns of type `text` (or types castable to `text` like `json`). Soon we will also support `bytea` and possibly more as use cases and tests get better.
+
+TCE uses one of PostgreSQL's lesser-known features: [`SECURITY LABEL`](https://www.postgresql.org/docs/current/sql-security-label.html). A security label can be thought of as a simple label which is attached to an object (a table, column, etc). Each label is scoped to an extension and that extension can provide security features depending on the label.
+
+Let's see a simple example of using `SECURITY LABEL` to encrypt a column using **pgsodium**.
+
+<div className="bg-gray-300 rounded-lg p-6 italic">
+
+</div>
+
+### One Key ID for the Entire Column
+
+For the simplest case, a column can be encrypted with one Key ID which must be of the type `aead-det` (as created above):
+
+```sql
+CREATE TABLE secrets (
+ id bigserial primary key,
+ secret_number text
+);
+
+SECURITY LABEL FOR pgsodium
+ ON COLUMN secrets.secret_number
+ IS 'ENCRYPT WITH KEY ID e348034b-3f07-4878-aad6-000511d12826';
+```
+
+The advantage of this approach is simplicity - the user creates one key and labels a column with it. The cryptographic algorithm for this approach uses a _nonceless_ encryption algorithm called `crypto_aead_det_xchacha20()`. This algorithm is written by the author of libsodium and can be found [here](https://github.com/jedisct1/libsodium-xchacha20-siv).
+
+Using one key for an entire column means that whoever can decrypt one row can decrypt them all from a database dump. Also changing (rotating) the key means rewriting the whole table.
+
+### One Key ID per Row
+
+A more fine grained approach would be storing one Key ID per row:
+
+```sql
+CREATE TABLE secrets (
+ id bigserial primary key,
+ secret text,
+ key_id uuid not null DEFAULT 'e348034b-3f07-4878-aad6-000511d12826'::uuid
+);
+
+SECURITY LABEL FOR pgsodium
+ ON COLUMN secrets.secret
+ IS 'ENCRYPT WITH KEY COLUMN key_id';
+```
+
+This approach ensures that a key for one user doesn't necessarily decrypt any others. While rows can share key IDs, they don't necessarily have to (unlike the first example above where one key id was used for the entire column). It also acts as a natural partition that can work in conjunction with Row Level Security to share distinct keys between owners.
+
+Notice also how there is a `DEFAULT` value for the `key_id`. In a way, this gives you the best of both approaches - encrypting the column when a per-row key ID is not provided. The downside to this approach is that you need to store one key ID per row, which takes up more disk space (but that's cheap!).
+
+### One Key ID per Row with Nonce Support
+
+The default cryptographic algorithm for the above approach uses a _nonceless_ encryption algorithm called [`crypto_aead_det_xchacha20()`](https://github.com/jedisct1/libsodium-xchacha20-siv). This algorithm has the advantage that it does not require nonce values, the disadvantage is that duplicate plaintexts will produce duplicate ciphertexts.
+
+Nonces are some extra cryptographic context that is used in many cryptographic algorithms to produce different ciphertexts, even if the plaintexts are the same. The nonce does not have to be secret, but it _does_ have to be unique. **pgsodium** comes with a useful function `pgsodium.crypto_aead_det_noncegen()` that will generate a cryptographically secure nonce for you, and in almost all cases it's best to use that function unless you know specifically what you are doing. In password hashing approaches, this is often similar to how a “salt” value is used to deduplicate password hashes.
+
+Duplicate ciphertexts cannot be used to “attack the key”, it can only reveal the duplication. However, duplication is still information. In our examples so far, an attacker might be able to use this information to determine that two accounts share the same secret. While not technically breaking the encryption, this still leaks information to an attacker.
+
+```sql
+CREATE TABLE secrets (
+ id bigserial primary key,
+ secret text,
+ key_id uuid not null DEFAULT 'e348034b-3f07-4878-aad6-000511d12826'::uuid,
+ nonce bytea default pgsodium.crypto_aead_det_noncegen()
+);
+
+SECURITY LABEL FOR pgsodium
+ ON COLUMN secrets.secret
+ IS 'ENCRYPT WITH KEY COLUMN key_id NONCE nonce';
+```
+
+This is the most secure form of TCE - there is a unique key ID and a unique nonce per row.
+
+### One Key ID per Row with Associated Data
+
+The encryption that is used for TCE is one of a family of functions provided by **libsodium** to do Authenticated Encryption with Associated Data or [AEAD Encryption](https://en.wikipedia.org/wiki/Authenticated_encryption). The “associated” data is plaintext (unencrypted) information that is mixed into the authentication signature of the encrypted data, such that when you authenticate the data, you also know that the associated data is authentic.
+
+AEAD is helpful because often you have metadata associated with a secret, which isn't confidential but must not be forged.
+
+In our secret example, we might associate a "`secret`" with an "`account_id`". But what if a malicious actor wanted to use someone else's secret on their own account? If someone could forge the `account_id` data column, swapping an `account_id` with their own `account_id`, then you could be tricked into using the wrong secret. By “associating” the `account_id` with the `secret`, it cannot be forged without throwing an error.
+
+Like above, this is done simply by extending the security label with the associated data column:
+
+```sql
+CREATE TABLE secrets (
+ id bigserial primary key,
+ secret text,
+ account_id integer,
+ key_id uuid not null DEFAULT 'e348034b-3f07-4878-aad6-000511d12826'::uuid,
+ nonce bytea default pgsodium.crypto_aead_det_noncegen()
+);
+
+SECURITY LABEL FOR pgsodium
+ ON COLUMN secrets.secret
+ IS 'ENCRYPT WITH KEY COLUMN key_id ASSOCIATED (account_id) NONCE nonce';
+```
+
+The new label indicates which column is to be associated with the secret, and that's it! Your `account_id` and secret are now protected under the same authentication signature as the secret itself.
+
+## Using an Encrypted Table
+
+Now that you have TCE setup for a table, it's easy to use by simply inserting data into the table, and querying that data by looking at its generated view. The view is named `decrypted_<table_name>` and by default is in the same schema as your table:
+
+```sql
+INSERT INTO secrets (
+ secret,
+ account_id
+)
+VALUES
+ ('1234-5678-8765-4321', 123);
+```
+
+Now that you have inserted data, look at the table and notice how the secret is encrypted. This is the data that is stored on disk, the encrypted card number, the key id, and the account id, **but the key itself is not stored**. This means if someone gets a backup or dump of your database, they cannot decrypt the secret, they do not have the key, only the key ID:
+
+```sql
+> select * from secrets where account_id = 123;
+-[ RECORD 1 ]------+---------------------------------------------------------------------
+id | 1
+secret | jf8KfImkKTr+j4gzyDZQtLDEFL9eSlFuKjNlNEJvDg+OIKUr2wjF/8NnYcLisb5F9xiN
+account_id | 123
+key_id | 7f753c4f-8c68-457a-8801-1798b2e9f44d
+nonce | \x300a14aa721184ff7cf0f6bf088da267
+```
+
+For you, the developer, you need the unencrypted secret for you application. No problem, you can access that data using the dynamically generated decryption view `decrypted_secrets`:
+
+```sql
+> select * from decrypted_secrets where account_id = 123;
+-[ RECORD 1 ]----------------+---------------------------------------------------------------------
+id | 1
+secret | jf8KfImkKTr+j4gzyDZQtLDEFL9eSlFuKjNlNEJvDg+OIKUr2wjF/8NnYcLisb5F9xiN
+decrypted_secret | 1234-5678-8765-4321
+account_id | 123
+key_id | 7f753c4f-8c68-457a-8801-1798b2e9f44d
+nonce | \x300a14aa721184ff7cf0f6bf088da267
+```
+
+Notice how there is a new column called `decrypted_secret`. This column is not stored in database or on disk at all, it is generated “on-the-fly” as you select from the view. Database dumps do not contain this information, only the view itself, and most importantly, **raw decryption keys are never stored**.
+
+
+![Decrypted data](/images/blog/launch-week-6/vault/vault-decrypted-data.png)
+
+- Read more about Supabase Vault in the [blog post](https://supabase.com/blog/vault-now-in-beta)
+- [Supabase Vault on GitHub](https://github.com/supabase/vault)
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/guides/database/vault.mdx b/apps/docs/pages/guides/database/vault.mdx
new file mode 100644
index 00000000000..6db4b456c02
--- /dev/null
+++ b/apps/docs/pages/guides/database/vault.mdx
@@ -0,0 +1,209 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'vault',
+ title: 'Vault',
+ description: 'Use Supabase to store and serve files.',
+ sidebar_label: 'Overview',
+ video: 'https://www.youtube.com/v/J9mTPY8rIXE',
+}
+
+Supabase Vault provides encrypted secret storage and Encrypted Columns for Tables
+
+## Vault
+
+Vault is a Postgres extension and accompanying Supabase UI that makes it safe and easy to store encrypted secrets and encrypt other stored data in your database. This foundation opens up a lot of possibilities for Postgres that go beyond what is available in a stock distribution. From a product perspective we're grouping various features under the “Vault banner”. Let's explore a few of these features.
+
+## Secrets Management
+
+Practically speaking, the Vault is a table of Secrets and Encryption Keys that are stored using [Authenticated Encryption](https://en.wikipedia.org/wiki/Authenticated_encryption) on disk, but available in decrypted form through a Postgres view so that the secrets can be used by applications from SQL. Because the secrets are stored encrypted and authenticated, any backups or replication streams also preserve this encryption in a way that can't be forged.
+
+We've created a dashboard UI for the Vault that makes storing secrets easy. Click a button and type in your secret, optionally create a new key that is referenced by id (or use the existing default), and submit. Your secret is now stored on disk encrypted using the specified key id.
+
+<video width="99%" muted playsInline controls="true">
+ <source
+ src="/images/blog/launch-week-6/vault/vault-hello-compressed.mp4"
+ type="video/mp4"
+ muted
+ playsInline
+ />
+</video>
+
+There are two main parts to the Vault UI, Secrets and Encryption Keys:
+
+- **Secrets:** Use the Vault to store Secrets - everything from Environment Variables to API Keys. You can use these Secrets anywhere in your database: Postgres [Functions](/docs/guides/database/functions), Triggers, and [Webhooks](/docs/guides/database/webhooks). From a SQL perspective, accessing secrets is as easy as querying a table (or in this case, a view). The underlying secrets tables will be stored in encrypted form.
+- **Encryption Keys:** encryption keys are used to encrypt data inside your database. Fun fact: the Secrets you store in the Vault are encrypted with an Encryption Key which we set up by default and is not accessible to SQL or stored in your database alongside the same data it is used to encrypt. You can create different Encryption Keys for different purposes, for example: one for encrypting user-data, and another for application-data.
+
+## Deep Dive on How The Vault works
+
+<div className="video-container">
+ <iframe
+ src="https://www.youtube-nocookie.com/embed/QHLPNDrdN2w"
+ title="YouTube video player"
+ frameborder="0"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowfullscreen
+ ></iframe>
+</div>
+
+As we mentioned, the Vault uses pgsodium's Transparent Column Encryption (TCE) to store secrets in an authenticated encrypted form. There are some details around that you may be curious about, what does authenticated mean, and where are encryption keys store? This section explains those details.
+
+The first important feature of TCE is that it uses an [Authenticated Encryption with Associated Data](<https://en.wikipedia.org/wiki/Authenticated_encryption#Authenticated_encryption_with_associated_data_(AEAD)>) encryption algorithm based on libsodium. “Authenticated Encryption” means that in addition to the data being encrypted, it is also “signed” so that it cannot be forged, the decryption function verifies that the signature is valid **before decrypting the value**. “Associated Data” means that in addition to signing the secret, you can include any other columns in your row in the signature computation, “associating” those columns with the secret. This doesn't encrypt those other columns, but it does ensure that **they are authentic** and cannot be forged because they are included in the secret's signature. So you know when you restore your database dumps, not only are the secrets safe, but also the “associated” columns are also authentic and unforged.
+
+Another important feature of pgsodium is that the encryption keys are never stored in the database alongside the encrypted data, instead, only a **Key ID** is stored, which refers to a key that is only accessible outside of SQL. Even if an attacker can capture a dump of your entire database, they will see only encrypted data and key ids, **never the raw key itself**. This is an important safety precaution, there would be no point in storing the encryption key in the database alongside the encrypted data, this would be like locking your front door but leaving the key in the lock! Storing the key outside the database fixes this issue.
+
+You might be wondering, ok then where are the keys stored? Supabase creates and manages the root keys from which all key ids are derived in our internal customer backend systems. We keep this key safe and separate from your data, and provide an alternate dashboard endpoint for accessing the key if you want to decrypt your data outside of Supabase.
+
+## Using the Vault
+
+Using the vault is as simple as `INSERT`ing data into the
+`vault.secret` table.
+
+```
+postgres=> INSERT INTO vault.secrets (secret) VALUES ('s3kre3t_k3y') RETURNING *;
+-[ RECORD 1 ]-------------------------------------------------------------
+id | d91596b8-1047-446c-b9c0-66d98af6d001
+name |
+description |
+secret | S02eXS9BBY+kE3r621IS8beAytEEtj+dDHjs9/0AoMy7HTbog+ylxcS22A==
+key_id | 7f5ad44b-6bd5-4c99-9f68-4b6c7486f927
+nonce | \x3aa2e92f9808e496aa4163a59304b895
+created_at | 2022-12-14 02:29:21.3625+00
+updated_at | 2022-12-14 02:29:21.3625+00
+```
+
+There is also a handy function for creating secrets called
+`vault.create_secret()`:
+
+```
+postgres=> select vault.create_secret('another_s3kre3t');
+-[ RECORD 1 ]-+-------------------------------------
+create_secret | c9b00867-ca8b-44fc-a81d-d20b8169be17
+
+```
+
+The function returns the UUID of the new secret.
+
+## Name and Description
+
+Secrets can also have an optional _unique_ name, or an optional description. These are also arguments to `vault.create_secret()`:
+
+```
+postgres=> select vault.create_secret('another_s3kre3t', 'unique_name', 'This is the description');
+-[ RECORD 1 ]-+-------------------------------------
+create_secret | 7095d222-efe5-4cd5-b5c6-5755b451e223
+
+postgres=> select * from vault.secrets where id = '7095d222-efe5-4cd5-b5c6-5755b451e223';
+-[ RECORD 1 ]-----------------------------------------------------------------
+id | 7095d222-efe5-4cd5-b5c6-5755b451e223
+name | unique_name
+description | This is the description
+secret | 3mMeOcoG84a5F2uOfy2ugWYDp9sdxvCTmi6kTeT97bvA8rCEsG5DWWZtTU8VVeE=
+key_id | c62da7a0-b85d-471d-8ea7-52aae21d7354
+nonce | \x9f2d60954ba5eb566445736e0760b0e3
+created_at | 2022-12-14 02:34:23.85159+00
+updated_at | 2022-12-14 02:34:23.85159+00
+```
+
+## Querying Data from the Vault
+
+If you look in the `vault.secrets` table, you will see that your data is stored encrypted. To decrypt the data, there is an automatically created view `vault.decrypted_secrets`. This view will decrypt secret data on the fly:
+
+```
+postgres=> select * from vault.decrypted_secrets order by created_at desc limit 3;
+-[ RECORD 1 ]----+-----------------------------------------------------------------
+id | 7095d222-efe5-4cd5-b5c6-5755b451e223
+name | unique_name
+description | This is the description
+secret | 3mMeOcoG84a5F2uOfy2ugWYDp9sdxvCTmi6kTeT97bvA8rCEsG5DWWZtTU8VVeE=
+decrypted_secret | another_s3kre3t
+key_id | c62da7a0-b85d-471d-8ea7-52aae21d7354
+nonce | \x9f2d60954ba5eb566445736e0760b0e3
+created_at | 2022-12-14 02:34:23.85159+00
+updated_at | 2022-12-14 02:34:23.85159+00
+-[ RECORD 2 ]----+-----------------------------------------------------------------
+id | c9b00867-ca8b-44fc-a81d-d20b8169be17
+name |
+description |
+secret | a1CE4vXwQ53+N9bllJj1D7fasm59ykohjb7K90PPsRFUd9IbBdxIGZNoSQLIXl4=
+decrypted_secret | another_s3kre3t
+key_id | 8c72b05e-b931-4372-abf9-a09cfad18489
+nonce | \x1d3b2761548c4efb2d29ca11d44aa22f
+created_at | 2022-12-14 02:32:50.58921+00
+updated_at | 2022-12-14 02:32:50.58921+00
+-[ RECORD 3 ]----+-----------------------------------------------------------------
+id | d91596b8-1047-446c-b9c0-66d98af6d001
+name |
+description |
+secret | S02eXS9BBY+kE3r621IS8beAytEEtj+dDHjs9/0AoMy7HTbog+ylxcS22A==
+decrypted_secret | s3kre3t_k3y
+key_id | 7f5ad44b-6bd5-4c99-9f68-4b6c7486f927
+nonce | \x3aa2e92f9808e496aa4163a59304b895
+created_at | 2022-12-14 02:29:21.3625+00
+updated_at | 2022-12-14 02:29:21.3625+00
+```
+
+Notice how this view has a `decrypted_secret` column that contains the decrypted secrets. Views are not stored on disk, they are only run at query time, so the secret remains encrypted on disk, and in any backup dumps or replication streams.
+
+You should ensure that you protect access to this view with the appropriate SQL privilege settings at all times, as anyone that has access to the view has access to decrypted secrets.
+
+## Updating Secrets
+
+A secret can be updated with the `vault.update_secret()` function, this function makes updating secrets easy, just provide the secret UUID as the first argument, and then an updated secret, updated optional unique name, or updated description:
+
+```
+postgres=> select vault.update_secret('7095d222-efe5-4cd5-b5c6-5755b451e223', 'n3w_upd@ted_s3kret',
+ 'updated_unique_name', 'This is the updated description');
+-[ RECORD 1 ]-+-
+update_secret |
+
+postgres=> select * from vault.decrypted_secrets where id = '7095d222-efe5-4cd5-b5c6-5755b451e223';
+-[ RECORD 1 ]----+---------------------------------------------------------------------
+id | 7095d222-efe5-4cd5-b5c6-5755b451e223
+name | updated_unique_name
+description | This is the updated description
+secret | lhb3HBFxF+qJzp/HHCwhjl4QFb5dYDsIQEm35DaZQOovdkgp2iy6UMufTKJGH4ThMrU=
+decrypted_secret | n3w_upd@ted_s3kret
+key_id | c62da7a0-b85d-471d-8ea7-52aae21d7354
+nonce | \x9f2d60954ba5eb566445736e0760b0e3
+created_at | 2022-12-14 02:34:23.85159+00
+updated_at | 2022-12-14 02:51:13.938396+00
+```
+
+## Internal Details
+
+To encrypt data, you need a *key id*. You can use the default key id created automatically for every project, or create your own key ids Using the `pgsodium.create_key()` function. Key ids are used to internally derive the encryption key used to encrypt secrets in the vault. Vault users typically do not have access to the key itself, only the key id.
+
+Both `vault.create_secret()` and `vault.update_secret()` take an optional fourth `new_key_id` argument. This argument can be used to store a different key id for the secret instead of the default value.
+
+```
+postgres=> select vault.create_secret('another_s3kre3t_key', 'another_unique_name',
+ 'This is another description', (pgsodium.create_key()).id);
+-[ RECORD 1 ]-+-------------------------------------
+create_secret | cec9e005-a44d-4b19-86e1-febf3cd40619
+```
+
+Which roles should have access to the `vault.secrets` table should be carefully considered. There are two ways to grant access, the first is that the `postgres` user can explicitly grant access to the vault table itself.
+
+## Turning off Statement Logging
+
+When you insert secrets into the vault table with an INSERT statement, those statements get logged by default into the Supabase logs. Since this would mean your secrets are stored unencrypted in the logs, you should turn off statement logging while using the Vault.
+
+While turning off statement logging does hinder you if you're used to looking at the logs to debug your application, it provides a much higher level of security by ensuring that your data does not leak out of the database and into the logs. This is especially critical with encrypted column data, because the statement logs will contain the *unencrypted* secrets. If you *must* store that data encrypted, then you *must* turn off statement logging.
+
+```
+ALTER SYSTEM SET statement_log = 'none';
+```
+
+And then restart your project from the dashboard to enable that change.
+
+In the future we are researching various ways to refine the way statement logging interacts with sensitive columns.
+
+## See also
+
+- Read more about Supabase Vault in the [blog post](https://supabase.com/blog/vault-now-in-beta)
+- [Supabase Vault on GitHub](https://github.com/supabase/vault)
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/package-lock.json b/package-lock.json
index 0881d78353b..9ed78cb140f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -68107,7 +68107,7 @@
"@types/react": "^17.0.37",
"@types/react-copy-to-clipboard": "^5.0.4",
"@types/react-dom": "^17.0.11",
- "@types/react-syntax-highlighter": "*",
+ "@types/react-syntax-highlighter": "^15.5.6",
"autoprefixer": "^10.4.2",
"clsx": "^1.2.1",
"cmdk-supabase": "^0.2.2",