Skip to content

Commit 7e5812f

Browse files
moscaaleAlessandro Moscaactions-user
authored
add username for redis connection (#496)
* add redis_username parameter * rebase * add docuementation * Update pyproject.toml version * Update unit coverage badge --------- Co-authored-by: Alessandro Mosca <a.mosca@octo.com> Co-authored-by: GitHub Actions <actions@github.com> Co-authored-by: moscaale <moscaale@users.noreply.github.com>
1 parent ab03de5 commit 7e5812f

6 files changed

Lines changed: 40 additions & 8 deletions

File tree

.github/badges/coverage-unit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"schemaVersion":1,"label":"unit coverage","message":"58.96%","color":"red"}
1+
{"schemaVersion":1,"label":"unit coverage","message":"58.95%","color":"red"}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ help:
9090
done
9191
@$(MAKE) .banner
9292
@printf "┌─────────────────────────────────────────────────────────────────────────────────────────┐\n"
93-
@printf "│ \033[1m🐳 Docker services\033[0m │\n"
93+
@printf "│ \033[1m🐳 Docker services\033[0m │\n"
9494
@printf "├─────────────────────────────────────────────────────────────────────────────────────────┤\n"
9595
@printf "\n"
9696
@printf " %-30s %s\n" "Compose file:" "$(compose)"

api/helpers/_limiter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def __init__(self, redis: ConnectionPool, strategy: LimitingStrategy):
1616
self.connection_pool = redis
1717
self.redis_host = self.connection_pool.connection_kwargs.get("host", "localhost")
1818
self.redis_port = self.connection_pool.connection_kwargs.get("port", 6379)
19+
self.redis_username = self.connection_pool.connection_kwargs.get("username", "")
1920
self.redis_password = self.connection_pool.connection_kwargs.get("password", "")
20-
self.redis = storage.RedisStorage(uri=f"async+redis://:{self.redis_password}@{self.redis_host}:{self.redis_port}", connection_pool=self.connection_pool) # fmt: off
21+
self.redis = storage.RedisStorage(uri=f"async+redis://{self.redis_username}:{self.redis_password}@{self.redis_host}:{self.redis_port}", connection_pool=self.connection_pool) # fmt: off
2122

2223
if strategy == LimitingStrategy.MOVING_WINDOW:
2324
self.strategy = strategies.MovingWindowRateLimiter(storage=self.redis)

compose.example.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ services:
5454
start_period: 60s
5555

5656
redis:
57-
image: redis/redis-stack-server:7.2.0-v11
57+
image: redis/redis-stack-server:7.4.0-v7
5858
restart: always
5959
environment:
6060
REDIS_ARGS: "--dir /data --requirepass ${REDIS_PASSWORD:-changeme} --user ${REDIS_USER:-redis} on >password ~* allcommands --save 60 1 --appendonly yes"
@@ -67,6 +67,7 @@ services:
6767
interval: 4s
6868
timeout: 10s
6969
retries: 5
70+
start_period: 60s
7071

7172
volumes:
7273
postgres:

docs/docs/dependencies/redis.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ These metrics are used for monitoring and can be exposed via Prometheus when ena
4040

4141
### Prerequisites
4242

43-
Redis Stack Server 7.2+ is required (includes the time-series module).
43+
Redis Stack Server 7.4+ is required (includes the time-series module).
4444

4545
### Configuration
4646

@@ -52,10 +52,10 @@ Add a `redis` container in the `services` section of your `compose.yml` file:
5252
services:
5353
[...]
5454
redis:
55-
image: redis/redis-stack-server:7.2.0-v11
55+
image: redis/redis-stack-server:7.4.0-v7
5656
restart: always
5757
environment:
58-
REDIS_ARGS: "--dir /data --requirepass ${REDIS_PASSWORD:-changeme} --user ${REDIS_USER:-redis} on >password ~* allcommands --save 60 1 --appendonly yes"
58+
REDIS_ARGS: "--loadmodule /opt/redis-stack/lib/redistimeseries.so --dir /data --requirepass ${REDIS_PASSWORD:-changeme} --user ${REDIS_USER:-redis} on >password ~* allcommands --save 60 1 --appendonly yes"
5959
ports:
6060
- "${REDIS_PORT:-6379}:6379"
6161
volumes:
@@ -65,6 +65,7 @@ services:
6565
interval: 4s
6666
timeout: 10s
6767
retries: 5
68+
start_period: 60s
6869

6970
volumes:
7071
redis:
@@ -112,3 +113,32 @@ For more information about the configuration file, see [Configuration](../gettin
112113
```
113114

114115
Theses metrics are stored in Redis time-series module to determine request prioritisation. For more information about request prioritisation, see [request prioritisation documentation](../models/request_prioritisation.md).
116+
117+
### Security
118+
119+
We recommend securing your Redis instance by keeping the version up-to-date.
120+
For production environment, we also recommend :
121+
- enabling protected mode
122+
- deactivating default user
123+
- create specific users with limited permissions
124+
- logging to specific log files
125+
- disabling syslog
126+
- disabling dangerous commands (FLUSHALL, FLUSHDB, etc.)
127+
128+
It can be done by configuring the `REDIS_ARGS` environment variable in the `docker-compose.yml` or with a redis.conf file.
129+
Also consider this security hardening for your docker compose service.
130+
131+
```
132+
redis:
133+
[...]
134+
security_opt:
135+
- no-new-privileges:true
136+
cap_drop:
137+
- ALL
138+
cap_add:
139+
- SETGID
140+
- SETUID
141+
read_only: true
142+
tmpfs:
143+
- /tmp:noexec,nosuid,size=64M
144+
```

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "opengatellm"
3-
version = "0.2.8post1"
3+
version = "0.2.8post2"
44
description = "OpenGateLLM project"
55
requires-python = ">=3.12"
66
license = { text = "MIT" }

0 commit comments

Comments
 (0)