Rotate database and mailbox passwords from the panel #70

Merged
parkel merged 3 commits from feature/service-credential-rotation into main 2026-11-21 19:24:30 +01:00
11 changed files with 192 additions and 3 deletions
Showing only changes of commit 0ab0eebfc6 - Show all commits

No files matched your search

@@ -0,0 +1,15 @@
Match User coulobre-mail-credential-request
AuthenticationMethods publickey
PubkeyAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
AuthorizedKeysFile /etc/ssh/coulobre-node-keys/%u
AuthorizedKeysCommand none
TrustedUserCAKeys none
DisableForwarding yes
PermitTunnel no
PermitTTY no
PermitUserRC no
ForceCommand /usr/bin/socat -t 92 STDIO UNIX-CONNECT:/run/coulobre-mail-credentials.sock
Match all
@@ -0,0 +1,13 @@
Host coulobre-mail-credentials
HostName mail.example.org
Port 22
User coulobre-mail-credential-request
IdentityFile /etc/coulobre-remote/mail-credentials/id_ed25519
IdentityAgent none
IdentitiesOnly yes
PreferredAuthentications publickey
UserKnownHostsFile /etc/coulobre-remote/mail-credentials/known_hosts
GlobalKnownHostsFile none
StrictHostKeyChecking yes
BatchMode yes
ConnectTimeout 5
+4
View File
@@ -18,6 +18,10 @@ COULOBRE_BROKER_URL=amqp://coulobre:@127.0.0.1:5672/coulobre
# COULOBRE_LOCAL_MAILBOX_PROVISIONING=1
# COULOBRE_LOCAL_DATABASE_CREDENTIALS=1
# COULOBRE_LOCAL_MAILBOX_CREDENTIALS=1
# COULOBRE_REMOTE_MAILBOX_CREDENTIALS=1
# COULOBRE_LOCAL_DATABASE_CREDENTIALS_ROTATION=1
# COULOBRE_LOCAL_MAILBOX_CREDENTIALS_ROTATION=1
# COULOBRE_REMOTE_MAILBOX_CREDENTIALS_ROTATION=1
# COULOBRE_MAIL_IMAP_HOST=mail.example.org
# COULOBRE_PHPMYADMIN_URL=https://tools.example.org/phpmyadmin
# COULOBRE_PHPMYADMIN_BRIDGE_KEY=
@@ -0,0 +1,11 @@
[Unit]
Description=Coulobre mailbox credential socket
[Socket]
ListenStream=/run/coulobre-mail-credentials.sock
SocketUser=root
SocketGroup=coulobre-credential-requests
SocketMode=0660
Accept=yes
MaxConnections=4
RemoveOnStop=true
@@ -0,0 +1,20 @@
[Unit]
Description=Coulobre mailbox credential request
After=postfix.service dovecot.service
CollectMode=inactive-or-failed
[Service]
Type=exec
User=root
WorkingDirectory=/opt/coulobre
UMask=0077
Environment=COULOBRE_LOCAL_MAILBOX_CREDENTIALS=1
ExecStart=/opt/coulobre/bin/coulobre-service-credentials --mailbox-only
StandardInput=socket
StandardOutput=socket
StandardError=journal
RuntimeMaxSec=90s
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
@@ -0,0 +1,9 @@
[Unit]
After=network-online.target
Wants=network-online.target
[Service]
User=coulobre-mail-credential-relay
ExecStart=
ExecStart=/usr/bin/ssh -T -F /etc/coulobre-remote/mail-credentials/ssh_config coulobre-mail-credentials
RuntimeMaxSec=95s
@@ -0,0 +1,4 @@
[Service]
Environment=COULOBRE_LOCAL_MAILBOX_CREDENTIALS_ROTATION=1
ReadWritePaths=-/var/lib/coulobre/mail-node /etc/dovecot
RuntimeMaxSec=90s
@@ -0,0 +1,6 @@
[Unit]
Requires=coulobre-mail-credentials.socket
After=coulobre-mail-credentials.socket
[Service]
SupplementaryGroups=coulobre-credential-requests
@@ -0,0 +1,4 @@
[Service]
Environment=COULOBRE_LOCAL_DATABASE_CREDENTIALS_ROTATION=1
ReadWritePaths=-/var/lib/coulobre/database-node
RuntimeMaxSec=90s
@@ -0,0 +1,4 @@
[Service]
Environment=COULOBRE_LOCAL_MAILBOX_CREDENTIALS_ROTATION=1
ReadWritePaths=-/var/lib/coulobre/mail-node /etc/dovecot
RuntimeMaxSec=90s
+102 -3
View File
@@ -730,12 +730,45 @@ assigned accounts. Operators need permission to view the account and resource
and the relevant **Can reveal database credentials** or **Can reveal mailbox
credentials** permission.
Passwords are read directly from the local service and rendered on the
confirmation response. The panel stores access events and outcomes in Django
Passwords are read from the service node and rendered on the confirmation
response. The panel stores access events and outcomes in Django
admin under **Service credential accesses**. The audit log includes the actor
and resource identifiers. After five incorrect confirmations within five
minutes, the panel temporarily stops accepting new attempts for that user.
### Rotate a database or mailbox password
Enable the corresponding local credential service first. For each local
service that should allow password rotation, install its rotation drop-in
and enable the matching flag in `/etc/coulobre/panel.env`.
```sh
# COULOBRE_LOCAL_DATABASE_CREDENTIALS_ROTATION=1
sudo install -D -m 0644 deploy/systemd/coulobre-service-credentials@.service.d/database-rotation.conf \
/etc/systemd/system/coulobre-service-credentials@.service.d/database-rotation.conf
# COULOBRE_LOCAL_MAILBOX_CREDENTIALS_ROTATION=1
sudo install -D -m 0644 deploy/systemd/coulobre-service-credentials@.service.d/mailbox-rotation.conf \
/etc/systemd/system/coulobre-service-credentials@.service.d/mailbox-rotation.conf
sudo systemctl daemon-reload
sudo systemctl restart coulobre-panel
```
Open **Connection details**, choose **Rotate password**, and confirm the
current panel password. A customer can rotate a login on their own account.
An operator needs the reveal permission and the corresponding **Can rotate
database credentials** or **Can rotate mailbox credentials** permission.
The service node generates the replacement. Copy it into any application
configuration or mail client using that login before its next connection.
A new phpMyAdmin sign-in reads the current database password.
If the panel cannot confirm the change, retry from the same form or reopen
it to resume the pending request. MariaDB data and grants, and mailbox
messages and quotas, are retained. Existing sessions can stay connected
until they close. The audit trail records the attempt and outcome. The
password stays in the node's root-only registry and is returned only on an
authorized confirmation. Resolve an unconfirmed rotation before suspending
the account or changing the affected mailbox's quota.
### Open phpMyAdmin from the panel
Enable database credential access first. Install phpMyAdmin with PHP's MySQL
@@ -1013,9 +1046,75 @@ corresponding retry action. Check the panel-side relay log with
When moving an existing service, migrate its data and provisioning state and
let outstanding jobs finish before switching destinations.
For mail on a separate server, retrieve logins on the mail node, and use the
For mail on a separate server, use the
[separate-node backup workflow](development.md#bundle-backups-from-separate-nodes).
### Enable connection details for remote mailboxes
Use a separate SSH identity for credential access. Install the same Coulobre
version on both ends. The key grants access to Coulobre-managed mailbox
logins on that receiver. Keep it with the relay account on the panel and
assign each mailbox domain to one sending installation.
On the panel node, create the relay user and its SSH directory. Generate a
dedicated key pair, copy the public half to the mail node, and install the
verified SSH host key for the destination as `known_hosts` in the relay
directory.
```sh
relay=coulobre-mail-credential-relay
dir=/etc/coulobre-remote/mail-credentials
getent group coulobre-credential-requests >/dev/null || sudo groupadd --system coulobre-credential-requests
sudo useradd --system --user-group --no-create-home --home-dir /nonexistent \
--shell /usr/sbin/nologin "$relay"
sudo install -d -o root -g "$relay" -m 0750 "$dir"
sudo install -o root -g "$relay" -m 0640 deploy/openssh/mail-credential-client.conf.example "$dir/ssh_config"
sudoedit "$dir/ssh_config"
# Install id_ed25519 with owner $relay and mode 0600.
# Install known_hosts with group $relay and mode 0640.
sudo install -m 0644 deploy/systemd/coulobre-mail-credentials.socket \
deploy/systemd/coulobre-mail-credentials@.service /etc/systemd/system/
sudo install -D -m 0644 deploy/systemd/coulobre-mail-credentials@.service.d/remote.conf \
/etc/systemd/system/coulobre-mail-credentials@.service.d/remote.conf
sudo install -D -m 0644 deploy/systemd/coulobre-panel.service.d/credentials-remote-mail.conf \
/etc/systemd/system/coulobre-panel.service.d/credentials-remote-mail.conf
```
On the mail node, save the panel's public key as `mail-credential.pub` and
install the credential receiver and local socket.
```sh
receiver=coulobre-mail-credential-request
getent group coulobre-credential-requests >/dev/null || sudo groupadd --system coulobre-credential-requests
sudo useradd --system --user-group --groups coulobre-credential-requests \
--no-create-home --home-dir / --shell /bin/sh "$receiver"
sudo install -d -m 0755 /etc/ssh/coulobre-node-keys
sudo install -m 0644 mail-credential.pub "/etc/ssh/coulobre-node-keys/$receiver"
sudo install -m 0644 deploy/openssh/coulobre-mail-credentials.conf.example \
/etc/ssh/sshd_config.d/01-coulobre-mail-credentials.conf
sudo install -m 0644 deploy/systemd/coulobre-mail-credentials.socket \
deploy/systemd/coulobre-mail-credentials@.service /etc/systemd/system/
sudo sshd -t
sudo systemctl daemon-reload
sudo systemctl reload-or-restart ssh.service
sudo systemctl enable --now coulobre-mail-credentials.socket
```
For rotation, also install the receiver's rotation drop-in on the **mail
node** and run `sudo systemctl daemon-reload` there.
```sh
sudo install -D -m 0644 deploy/systemd/coulobre-mail-credentials@.service.d/rotation.conf \
/etc/systemd/system/coulobre-mail-credentials@.service.d/rotation.conf
```
On the panel, set `COULOBRE_REMOTE_MAILBOX_CREDENTIALS=1` and, for password
changes, `COULOBRE_REMOTE_MAILBOX_CREDENTIALS_ROTATION=1`. Set
`COULOBRE_MAIL_IMAP_HOST` to the mail server's client-facing hostname. Run
`panel_manage migrate --noinput`, reload systemd, and restart
`coulobre-panel`. These flags route mailbox credential requests to the
remote receiver, while databases still use the local credential service.
## Manage resellers
Open **Resellers** to add a reseller login or change an existing reseller's