1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos-docs synced 2026-11-28 08:46:45 +01:00

docs: align Thalos docs with current config, CLI, and API

This commit is contained in:
Henrik Hautakoski 2026-08-31 14:51:54 +02:00
parent 2d90392d97
commit 3bb8bb5c26
11 changed files with 516 additions and 450 deletions

View file

@ -1,116 +1,91 @@
# ACL
By default, Redis does not impose any restrictions on the commands that clients can execute. This lack of
restrictions raises security concerns, especially when dealing with clients that may not be fully trusted.
However, there is no need to worry as Redis offers a solution in the form of [Access Control Lists (ACL)](https://en.wikipedia.org/wiki/Access-control_list).
Redis ACLs let you control **which commands** and **which channels/keys** each user can access.
For Thalos, this is the main way to safely separate:
ACL in Redis enables the establishment of limited access for connections to the server, specifying which
commands they are allowed to execute. In Thalos, this feature is crucial for maintaining security, ensuring
that clients can only access specific channels within Thalos.
- subscriber access (read from Thalos channels)
- server access (publish messages + state/cache reads/writes)
The special account called `default` serves as the default account for unauthorized users, provided it is
configured with a password. Connections can authenticate against this account without specifying a username.
Thalos utilizes this account as the default user account.
## Recommended user model
Additionally, it is advisable to restrict the Thalos server account as an added precaution against any
unauthorized actions it may inadvertently perform, although such occurrences are highly unlikely.
For a simple setup, use two users:
The ACL in thalos is simple and uses 2 accounts:
- `default` (or `thalos-client`) for subscribers
- `thalos` for thalos-server
* `default` account (user account, used by clients. only allowed to read from thalos specific channels)
* `thalos-server` account (is allowed to publish to channels and also write to it's cache)
there is also the `admin` account that is use for redis mangement. has access to everything.
::: danger IMPORTANT
Make sure you replace the passwords with a secure ones.
It is recommended to use [ACL GENPASS](https://redis.io/commands/acl-genpass) to generate strong passwords.
::: warning IMPORTANT
Use strong passwords. `ACL GENPASS` is recommended:
<https://redis.io/docs/latest/commands/acl-genpass/>
:::
`redis.conf`
## Example ACL rules
```
user default on >client_password resetchannels &ship::* +@connection +subscribe
user admin on >admin_password ~* &* +@all
user thalos on >server_password resetchannels &ship::* ~thalos::* +@connection +@read +@write +publish
Update `ship::*` if you use a different `redis.prefix`.
```conf
user default on >client_password resetkeys resetchannels &ship::* -@all +@connection +subscribe +psubscribe +unsubscribe +punsubscribe
user thalos on >server_password resetkeys resetchannels ~ship::* &ship::* -@all +@connection +get +set +publish
```
## External file
### Why both `~...` and `&...`?
It is possible to use external config files to define users in redis.
- `~pattern` controls key access
- `&pattern` controls Pub/Sub channel access
Just place the configuration above in an external file for example: `/etc/redis/users.acl` and then add this in `/etc/redis/redis.conf`
They are separate controls in Redis ACL.
```
## External ACL file
Store ACL rules in a dedicated file, then reference it from `redis.conf`:
```conf
aclfile /etc/redis/users.acl
```
## Thalos tools
## Thalos tooling
There is also a tool to create the config lines for you.
```
$ thalos-tools redis-acl
Passwords
default: NgCseRB8QcxdHwcwmg43OOjxZW0YbngN
thalos: kmJIi1kP5bp2MHQeSj925otWnxTvfRe5
thalos-client: WBGP9mXuUIIv11KhLgbuaTcl1NnRmhWn
# Created by thalos-tools on Mon Feb 12 15:56:26 CET 2024
user default on #3c0745d926021292a521267d803b9c20f3570bee30697e401920151d2593d1e4 ~* &* +@all
user thalos on #cf2b3e36521b0e67cb50fcc1f931f577384bb84ad7d0492d00e07beb4660ff1d resetchannels ~ship::* &ship::* -@all +get +publish +set
user thalos-client on #06d88f1e91d8bc82a5074223fd380006395b80a7b41dcd1318be1dd288282e4a resetchannels &ship::* -@all +subscribe
```
## Test the accounts permissions
It is a good idea to test if the configuration works.
Thalos includes an ACL helper:
```sh
$ redis-cli --pass mypassword
127.0.0.1:6379> SUBSCRIBE some_channel
Reading messages... (press Ctrl-C to quit)
(error) NOPERM this user has no permissions to access one of the channels used as arguments
127.0.0.1:6379> SET random_key value
(error) NOPERM this user has no permissions to run the 'set' command or its subcommand
127.0.0.1:6379> SUBSCRIBE ship::1234
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "ship::1234"
3) (integer) 1
thalos-tools redis-acl
```
You can customize generated users/prefix with flags such as:
- `--server`
- `--client`
- `--prefix`
- `--cleartext`
Review generated rules before applying them in production.
## Verify permissions
Test that subscriber credentials can only access allowed channels:
```sh
redis-cli --user default --pass client_password
```
Then try:
- `SUBSCRIBE ship::1234::actions` ✅
- `SUBSCRIBE some_other_prefix::1234::actions` ❌ (`NOPERM` expected)
- `SET random_key value` ❌ (`NOPERM` expected)
## Thalos config
After you have setup ACL, make sure to update your `config.yml` with the account and password.
After ACL setup, configure thalos-server with the server user:
```yaml
redis:
user: thalos
password: p4ssw0rd
```
## Other ACL Configurations
### No user password
While not recommended, it is possible to have the default (user) account without password. that way the user does not need to authenticate (but still has limited access). just remove the password from `user default` line:
```
user default on resetchannels &ship::* +@connection +subscribe
```
### Thalos users with a different account
It is also possible to provide a different account for users
```
user thalos-client on >client_password resetchannels &ship::* +@connection +subscribe
password: server_password
```
## Useful links
* [Config File Example](https://redis.io/docs/management/config-file)
* [Official ACL Documentation](https://redis.io/docs/management/security/acl)
- [Redis ACL documentation](https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/)
- [ACL SETUSER command](https://redis.io/docs/latest/commands/acl-setuser/)
- [ACL CAT command](https://redis.io/docs/latest/commands/acl-cat/)
- [Redis Pub/Sub](https://redis.io/docs/latest/develop/pubsub/)

View file

@ -1,51 +1,49 @@
# Securing Redis
# Securing redis
This guide focuses on Redis deployments where other systems or users can connect
to the same Redis server as Thalos.
This documentation primarily focuses on setups where Redis is exposed to the internet or an internal
network where there is not complete control over the clients.
For example, you may want to grant access to your Thalos instance to a friend.
While trusting your friend is reasonable, it is essential to consider potential future scenarios where
trust may no longer exist or their server could be compromised.
## Baseline recommendations
If you intend to run Thalos for internal use only, such as having internal applications that are relying on a blockchain stream,
it is perfectly acceptable to skip these steps if you have complete control over all involved
servers and do not expose the instance over a public IP.
1. Do not expose Redis directly to the public internet.
2. Restrict network access (bind + firewall/security groups).
3. Use ACL users with least privilege (see [ACL](/docs/redis/security/acl)).
4. Use TLS when traffic crosses untrusted networks.
## Isolating redis
## Isolating Redis
To ensure security, it is highly recommended to run Thalos on a dedicated Redis instance, ideally within a
container or virtual machine.
This isolation helps prevent data leaks in case of misconfigured Redis ACLs or unauthorized access due to
leaked/guessed admin password.
Running Thalos on a dedicated Redis instance (or dedicated DB/service) reduces
blast radius if credentials leak or ACL rules are misconfigured.
Additionally, it safeguards against potential misconfigurations, such as other applications mistakenly
writing sensitive data to Redis channels that can be accessed by Thalos clients.
It also lowers the risk of other applications accidentally publishing sensitive
data to channels your subscribers can read.
In summary, isolating Thalos in its own Redis instance provides an extra layer of safety.
## Network and protected mode
## Network
Use `bind` in `redis.conf` to restrict interfaces:
The `bind` directive in `redis.conf` is used to tell redis what network interfaces it should bind to.
Make sure to update this with the interfaces you intend to use.
```conf
bind 127.0.0.1 ::1 # loopback only
bind 192.168.1.100 10.0.0.1 # specific interfaces
```
::: danger IMPORTANT
Although it is recommended to limit Redis to the localhost interface for security purposes, with proper
firewall and ACL configurations, it can be safely exposed to additional interfaces. Carefully evaluate the necessity of
external access before making the change in the config file.
::: warning
`protected-mode` is a safety fallback, not a full security model.
For production, still enforce strict network controls and ACLs.
:::
```
bind 192.168.1.100 10.0.0.1 # listens on two specific IPv4 addresses
bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6
bind * -::* # like the default, all available interfaces
```
## Firewall
Make sure you setup your firewall rules correctly. Only allowing the IP addresses you trust to access the Redis port.
This is out of scope of this documentation. Consult your operating system or router manuals.
Allow Redis port access only from trusted hosts/subnets.
Firewall setup is environment-specific, so refer to your platform docs.
## TLS
Redis supports native TLS (Redis 6+).
When using TLS-only deployments, disable plaintext (`port 0`) and use `tls-port`.
## Useful links
* [Official Security Documentation](https://redis.io/docs/management/security)
* [Config File Example](https://redis.io/docs/management/config-file)
- [Redis security overview](https://redis.io/docs/latest/operate/oss_and_stack/management/security/)
- [Redis ACL documentation](https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/)
- [Redis TLS documentation](https://redis.io/docs/latest/operate/oss_and_stack/management/security/encryption/)