diff --git a/CHANGELOG.md b/CHANGELOG.md index da05a36c85..b47d981f1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `order_queryset` report helper function in [#10439](https://github.com/inventree/InvenTree/pull/10439) - Added much more detailed status information for machines to the API endpoint (including backend and frontend changes) in [#10381](https://github.com/inventree/InvenTree/pull/10381) - Added ability to partially complete and partially scrap build outputs in [#10499](https://github.com/inventree/InvenTree/pull/10499) +- Added support for Redis ACL user-based authentication in [#10551](https://github.com/inventree/InvenTree/pull/10551) ### Changed diff --git a/docs/docs/start/config.md b/docs/docs/start/config.md index b3163a9a4a..228e19fc40 100644 --- a/docs/docs/start/config.md +++ b/docs/docs/start/config.md @@ -309,6 +309,7 @@ The following cache settings are available: | INVENTREE_CACHE_HOST | cache.host | Cache server host | *Not specified* | | INVENTREE_CACHE_PORT | cache.port | Cache server port | 6379 | | INVENTREE_CACHE_PASSWORD | cache.password | Cache server password | none | +| INVENTREE_CACHE_USER | cache.user | Cache server username | none | | INVENTREE_CACHE_CONNECT_TIMEOUT | cache.connect_timeout | Cache connection timeout (seconds) | 3 | | INVENTREE_CACHE_TIMEOUT | cache.timeout | Cache timeout (seconds) | 3 | | INVENTREE_CACHE_TCP_KEEPALIVE | cache.tcp_keepalive | Cache TCP keepalive | True | diff --git a/src/backend/InvenTree/InvenTree/cache.py b/src/backend/InvenTree/InvenTree/cache.py index fb3d050289..3d56a11815 100644 --- a/src/backend/InvenTree/InvenTree/cache.py +++ b/src/backend/InvenTree/InvenTree/cache.py @@ -43,6 +43,11 @@ def cache_password(): return cache_setting('password', None) +def cache_user(): + """Return the cash username.""" + return cache_setting('user', None) + + def is_global_cache_enabled() -> bool: """Check if the global cache is enabled. @@ -85,9 +90,10 @@ def get_cache_config(global_cache: bool) -> dict: if global_cache: # Build Redis URL with optional password password = cache_password() + user = cache_user() or '' if password: - redis_url = f'redis://:{password}@{cache_host()}:{cache_port()}/0' + redis_url = f'redis://{user}:{password}@{cache_host()}:{cache_port()}/0' else: redis_url = f'redis://{cache_host()}:{cache_port()}/0'