> For the complete documentation index, see [llms.txt](https://ispectra.gitbook.io/mutamad/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ispectra.gitbook.io/mutamad/reference/settings.md). Agents can also search and read this documentation through its [MCP server](https://ispectra.gitbook.io/mutamad/~gitbook/mcp).

# Settings reference

Every setting, environment variable and file a Mutamad site reads.

## Files

| File                                     | What it holds                                      | Edit?                                                                |
| ---------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------- |
| `web/sites/default/settings.php`         | Drupal's settings; loads `settings.mutamad.php`    | Created by the installer                                             |
| `web/sites/default/settings.mutamad.php` | Mutamad's hardened settings                        | Scaffolded by the project template; set `trusted_host_patterns` here |
| `web/sites/default/services.mutamad.yml` | Monolog: database log and syslog JSON              | Scaffolded                                                           |
| `web/sites/default/settings.local.php`   | The server's own values: database, salt, hosts, AI | Yours; never in the repository                                       |
| `private-files/`                         | Private uploads                                    | Outside the web root                                                 |
| `private-files/mutamad-keys/tfa.key`     | The MFA encryption key                             | Never replace; back up with secrets                                  |

## settings.php keys

| Key                                                                        | Purpose                                                 | Example                                             |
| -------------------------------------------------------------------------- | ------------------------------------------------------- | --------------------------------------------------- |
| `$settings['trusted_host_patterns']`                                       | The addresses the site answers to (ECC 2-15)            | `['^www\.example\.gov\.sa$']`                       |
| `$settings['hash_salt']`                                                   | Read from a file outside the repository                 | `trim(file_get_contents('/etc/mutamad/hash_salt'))` |
| `$settings['file_private_path']`                                           | Private files                                           | `'../private-files'` (set by the template)          |
| `$settings['mutamad_ai']`                                                  | The model server for `mutamad_ai`                       | See below                                           |
| `$config['key.key.mutamad_tfa']['key_provider_settings']['file_location']` | Move the MFA key elsewhere, for example a secrets mount | `'/run/secrets/mutamad_tfa.key'`                    |

### The AI server

```php
$settings['mutamad_ai'] = [
  'endpoint' => 'https://ai.example.gov.sa/v1',  // OpenAI-compatible API
  'chat_model' => 'qwen2.5:14b',                 // writes and translates
  'vision_model' => 'qwen2.5vl:7b',              // describes images
  'embeddings_model' => 'bge-m3',                // chatbot only
];
```

## Environment variables

| Variable              | Used by            | Purpose                                                                                                                |
| --------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| `MUTAMAD_MAILER_DSN`  | Project template   | The mail relay, for example `smtp://user:password@relay.example.gov.sa:587`. Without it, mail goes through `sendmail`. |
| `MUTAMAD_AI_KEY`      | `mutamad_ai`       | The model server's key; any value for a server that asks for none                                                      |
| `MUTAMAD_FIGMA_TOKEN` | `mutamad_ai/figma` | Figma API token for AI Figma (administrator only)                                                                      |
| `MUTAMAD_URL`         | `mutamad-verify`   | The site's address, when run outside DDEV                                                                              |
| `STORYBOOK_THEME`     | Storybook          | A theme generated from `mutamad_theme`                                                                                 |

## The MFA encryption key

The installer generates it. On a site the installer did not build, create it before applying `mutamad_crypto`:

```bash
KEYS='/var/www/example.gov.sa/private-files/mutamad-keys'
mkdir -p "$KEYS"
head -c 32 /dev/urandom | base64 > "$KEYS/tfa.key"
chmod 640 "$KEYS/tfa.key"
```

{% hint style="danger" %}
**Never replace an existing key file.** Every user enrolled in MFA would be locked out. Back key files up with the site's secrets, not with its database.
{% endhint %}

## Hardened defaults

Set by `settings.mutamad.php` and `services.mutamad.yml`:

| Setting                    | Value                                                   | Control      |
| -------------------------- | ------------------------------------------------------- | ------------ |
| Private files              | `private-files/`, beside `web/`                         | ECC 2-7-2    |
| Session cookie             | Ends when the browser closes                            | ECC 2-2-3    |
| Session garbage collection | 12 hours                                                | ECC 2-2-3    |
| Strict session IDs         | On                                                      | ECC 2-2-3    |
| `update.php`               | Not anonymously                                         | ECC 2-15     |
| `X-Powered-By`             | Removed                                                 | ECC 2-15     |
| PHP floor                  | 8.3                                                     | ECC 2-10-3   |
| Logging                    | Database log and syslog JSON, `LOCAL0`, ident `mutamad` | ECC 2-12-3-3 |
| Fast 404                   | Lets `/.well-known/` through for security.txt           | —            |
| Storybook services         | Loaded under DDEV only                                  | ECC 2-15     |

## Recipe inputs

| Recipe                 | Input                                              | Default                     |
| ---------------------- | -------------------------------------------------- | --------------------------- |
| `mutamad_security`     | `security_contact` — the contact in `security.txt` | The site's email            |
| `mutamad_multilingual` | Configuration language lock                        | The site's default language |

## Libraries served by the site

The Content Security Policy allows no CDN, so these are installed into `web/libraries` by the root `composer.json`:

| Library  | Package         | Used by           |
| -------- | --------------- | ----------------- |
| Tagify   | `yaireo/tagify` | The Tags widget   |
| Dropzone | `enyo/dropzone` | Media bulk upload |

`mutamad-verify` fails if either is missing.
