|
11 | 11 | the machinery in ``vgi.catalog._descriptor_spec``. |
12 | 12 |
|
13 | 13 | Credential options (API keys, tokens, passwords) MUST be declared |
14 | | -``secret=True``. Clients and the DuckDB extension then mask the value, keep it |
15 | | -out of result-cache keys and logs, and can supply it from a ``vgi_attach`` |
16 | | -DuckDB secret instead of the ``ATTACH`` text:: |
| 14 | +``secret=True``. The caller passes them inline as attach options; the DuckDB |
| 15 | +extension redacts them from ``duckdb_databases()``, keeps only a salted hash of |
| 16 | +them in its result-cache key, and never logs them. To keep a credential out of |
| 17 | +the SQL text, write the option as an expression:: |
17 | 18 |
|
18 | | - CREATE SECRET (TYPE vgi_attach, SCOPE 'https://worker.example.com', api_key '...'); |
19 | | - ATTACH 'mydb' AS mydb (TYPE vgi, LOCATION 'https://worker.example.com'); |
| 19 | + ATTACH 'mydb' (TYPE vgi, LOCATION 'https://worker.example.com', api_key getenv('MYDB_API_KEY')); |
20 | 20 | """ |
21 | 21 |
|
22 | 22 | from dataclasses import dataclass |
@@ -51,11 +51,12 @@ class AttachOptionSpec(_SpecBase): |
51 | 51 | Mutually exclusive with ``default`` — an option that falls back to |
52 | 52 | a value is by definition satisfiable without the caller. |
53 | 53 | secret: The option carries a credential (an API key, token or |
54 | | - password). Clients and the DuckDB extension mask its value, keep it |
55 | | - out of result-cache keys and logs, and can supply it from a |
56 | | - ``vgi_attach`` DuckDB secret |
57 | | - (``CREATE SECRET (TYPE vgi_attach, SCOPE '<worker url>', api_key '...')``) |
58 | | - rather than the ``ATTACH`` text. Credential options MUST set this. |
| 54 | + password). It is still passed inline at ``ATTACH``, but clients |
| 55 | + mask it, and the DuckDB extension redacts it from |
| 56 | + ``duckdb_databases()``, keeps only a salted hash of it in its |
| 57 | + result-cache key, and never logs it. Keep it out of the SQL text |
| 58 | + with an expression, e.g. ``api_key getenv('MYDB_API_KEY')``. |
| 59 | + Credential options MUST set this. |
59 | 60 | Compatible with ``required``. Allowed alongside a ``default``, but a |
60 | 61 | secret option should normally have none: a default credential is |
61 | 62 | advertised in plain text to every client at discovery. |
@@ -123,9 +124,8 @@ class AttachOptions: |
123 | 124 | Attributes: |
124 | 125 | required: The caller must supply this option at ``ATTACH`` time. |
125 | 126 | secret: The option carries a credential. Clients and the DuckDB |
126 | | - extension mask it, keep it out of cache keys and logs, and can |
127 | | - supply it from a ``vgi_attach`` DuckDB secret. Should normally have |
128 | | - no default. |
| 127 | + extension mask it, keep only a salted hash of it in cache keys, and |
| 128 | + never log it. Should normally have no default. |
129 | 129 |
|
130 | 130 | """ |
131 | 131 |
|
|
0 commit comments