Skip to content

feat(broker): car-only MQTT user on a login-only listener (#1962) - #1963

Merged
groupsky merged 2 commits into
masterfrom
feat/1962-mqtt-car-user
Nov 18, 2026
Merged

groupsky merged 2 commits into
masterfrom
feat/1962-mqtt-car-user

Conversation

@groupsky

@groupsky groupsky commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Refs #1962

A car-only MQTT user, checked by the broker, on a new login-only listener.

What changes

  • config/mosquitto/broker.conf: per_listener_settings true. Port 1883 stays anonymous. New port 1884 needs a login and uses config/mosquitto/car.acl.
  • config/mosquitto/car.acl: user ioniq may read and write only ioniq/parsed/#, ioniq/raw/#, ioniq/log, ioniq/status, and only read homy/ioniq/journeys, homy/ioniq/road_check, homy/ioniq/home. Nothing else.
  • docker/mosquitto/entrypoint.sh: copies the deployed password file to a place the broker owns. If the file is missing, it makes an empty one, so the broker still starts.
  • docker-compose.yml: publishes 1884, mounts car.acl and the folder ${SECRETS_PATH}/mosquitto (read-only).
  • Test: .github/scripts/test-mqtt-car-user/run.sh + workflow test-mqtt-car-user.yml.
  • Doc: docs/mqtt-car-user.md (password file, how to add the user).

Choices and why

  • The car's topics are ioniq/..., not homy/ioniq/.... The car app publishes ioniq/parsed/<group>, ioniq/raw/<group>, ioniq/log, and its will/status topic ioniq/status. It subscribes to nothing today. Its user name is already ioniq. So the ACL gives write on exactly those four (not ioniq/#: ioniq/derived/# comes from the automations, and the car must not fake it). Where the issue says "under homy/ioniq/" and "nothing outside homy/ioniq/", read: the car's real topics above, plus read-only on ev-journal's. ev-journal's topics under homy/ioniq/ are read-only for the car, and everything else is closed.
  • A second listener, not a login for every client (option b). Clients use the published port 1883 without a login today: monitoring on other hosts and two services on routy itself. A login on 1883 would stop them. So 1883 stays as it is, and the car moves to 1884. Closing 1883 to outside clients is a later step, after those clients get logins.
  • Folder mount, not file mount. Tests showed that mosquitto 2.0.22 stops when the password file is missing or is readable only by root. Docker makes a folder in place of a missing bind-mounted file. So compose mounts the folder, and the entrypoint copies the file (or makes an empty one, so nobody can log in on 1884). A deploy without the file keeps the broker running.
  • use_username_as_clientid true on 1884: client ids are shared by both listeners, so a 1884 user could otherwise take a 1883 client's id and push it off.
  • Nothing changes for the car until someone sets port 1884 and the password in the app (docs/mqtt-car-user.md).

Progress

  • The broker config has the car user's ACL (in the repo; no passwords in the repo).
  • CI test starts mosquitto with this config: the car publishes to a car topic, reads homy/ioniq/journeys and homy/ioniq/road_check, cannot publish to homy/ioniq/journeys, cannot read or write outside its topics; a client without a login cannot use 1884. Also: the broker starts without a password file.
  • Docs: which file the deploy provides, and how to add the car user.
  • Review round 1 (fixed: write rights narrowed, client id, test checks "not authorised", doc command).
  • CI green, merged.

@groupsky
groupsky marked this pull request as ready for review November 18, 2026 08:04
@groupsky
groupsky merged commit 7305eec into master Nov 18, 2026
31 checks passed
@groupsky
groupsky deleted the feat/1962-mqtt-car-user branch November 18, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant