mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
feat(mail-ingest): the transport settings in the admin form, each overridable from the environment
The IMAP box, the webhook secret and the address template join the admin settings form (masked, encrypted, held by the operator on a managed install), and MAIL_INGEST_* variables override them through the mailIngestConfig token. The audit row masks every masked key, and key rotation covers the new secrets.
This commit is contained in:
@@ -317,6 +317,9 @@ async function main() {
|
||||
// service_key is the installation's key towards the liketrek services.
|
||||
// Missed here it reads back as unusable, the installation registers anew and
|
||||
// loses its id, and a revoked key would come back as a fresh one.
|
||||
//
|
||||
// The mail import's IMAP password and webhook secret: missed, the box stops
|
||||
// being read and every signed mail is refused until an admin types them again.
|
||||
for (const key of [
|
||||
'oidc_client_secret',
|
||||
'smtp_pass',
|
||||
@@ -327,6 +330,8 @@ async function main() {
|
||||
'amap_api_key',
|
||||
'web_push_vapid_private_key',
|
||||
'service_key',
|
||||
'mail_ingest_imap_pass',
|
||||
'mail_ingest_webhook_secret',
|
||||
]) {
|
||||
const row = db.prepare('SELECT value FROM app_settings WHERE key = ?').get(key) as { value: string } | undefined;
|
||||
if (!row?.value) continue;
|
||||
@@ -567,6 +572,28 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// --- mail_ingest: forwarding address tokens and the stored mails ---
|
||||
// A person sees their address again through its token_enc; a forwarded mail
|
||||
// waits for its reading, and for the inbox's ways out, as raw_eml_enc. Missed,
|
||||
// the addresses still take mail (they are found by hash) but show as unset,
|
||||
// and every stored mail reads as unreadable.
|
||||
for (const [table, column] of [
|
||||
['mail_ingest_addresses', 'token_enc'],
|
||||
['mail_ingest_messages', 'raw_eml_enc'],
|
||||
] as const) {
|
||||
if (!tableExists(table)) continue;
|
||||
const rows = db.prepare(`SELECT id, ${column} AS value FROM ${table} WHERE ${column} IS NOT NULL`).all() as {
|
||||
id: number;
|
||||
value: string;
|
||||
}[];
|
||||
for (const row of rows) {
|
||||
const newVal = migrateApiKeyValue(row.value, `${table}[${row.id}].${column}`);
|
||||
if (newVal !== null) {
|
||||
db.prepare(`UPDATE ${table} SET ${column} = ? WHERE id = ?`).run(newVal, row.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- addons: the AI Parsing addon's instance-wide API key ---
|
||||
// Stored encrypted as `apiKey` inside the addon's JSON config
|
||||
// (llm-parse/llm-config.ts). Left out, LLM parsing quietly runs without a
|
||||
|
||||
Reference in New Issue
Block a user