How to address production security considerations

This guide lists the security controls you must set up around eventsource in production. The library provides some of them. You provide the rest. Each section states which is which.

Before you start

Encrypt broker connections (TLS)

Traffic between your application and a broker can carry event payloads and credentials. Use TLS on every connection that leaves a trusted network.

The RabbitMQ and Redis adapters warn when a URL uses a plain scheme (amqp:// or redis://) and points at a remote host. Treat that warning as a failed check. Do not ignore it.

Keep secrets out of code

The library hides user names and passwords in connection URLs when the RabbitMQ and Redis adapters build a repr of their configuration. Do not depend on this for log output. Do not log a raw connection string or a config object yourself.

Redact logs

Limit tenant isolation

Read the multi-tenancy guide before you rely on tenant boundaries. These limits apply:

Validate read-model query input

The library validates read-model queries before it runs them. The check covers the types and ranges of limit and offset, the sort direction, and whether order_by names a field of the model.

Validation does not decide which fields a user may sort by. Keep an allow-list in your application:

Protect operator operations

These operations change or replay data. They are for operators, not end users:

Put access control in front of each one. Expose them only through authenticated tooling, such as an internal admin service or a command-line tool that runs with operator credentials. Do not expose them on a public endpoint. Log each operator action with the operator identity.

Encrypt payloads at rest

The library has no built-in hook for encrypting event payloads or read-model data. Choose one of these controls:

Encryption at rest protects data on disk. It does not protect data that an authorized database user reads.

Restrict snapshot tables

Snapshot state is read back and used to rebuild aggregates. The library treats the stored snapshot as trusted input. A changed snapshot changes the aggregate that loads from it. Restrict write access to snapshot tables:

Set SQLite file permissions

A SQLite event store is one file. Anyone who can read the file can read every event and snapshot in it. Set the file to be readable and writable only by the service user. For example, chmod 600 on the database file and chmod 700 on its directory. Keep the file out of shared or world-readable paths.

The library creates a new database file with mode 0600. It does not change the mode of a file that exists. SQLite creates the -wal and -shm files with the mode of the database file, so set the mode on the database file.

Checklist

See also