Add Authentik SSO service and refactor Valkey configuration to use native tools and consolidated systemd service

This commit is contained in:
2025-11-22 21:36:23 +01:00
parent 500224b5de
commit d814369c99
21 changed files with 769 additions and 74 deletions

View File

@@ -1,49 +0,0 @@
# Redis Systemd Security Override
# Generated by rick-infra Redis role
#
# This file provides additional security hardening for the Redis service
# following the same security patterns as the PostgreSQL role.
[Service]
# Security hardening
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectSystem=strict
ProtectHome=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
# Network security
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
# Filesystem permissions
ReadWritePaths=/var/lib/valkey
ReadOnlyPaths=/etc/valkey
# System call filtering
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources @obsolete
# Memory and resource limits
MemoryDenyWriteExecute=yes
LockPersonality=yes
# Capabilities
CapabilityBoundingSet=
AmbientCapabilities=
# User and group isolation
DynamicUser=no
User=valkey
Group=valkey
# Process isolation
PrivateUsers=yes
RemoveIPC=yes
# Additional Redis-specific security
UMask=0027

View File

@@ -31,7 +31,7 @@ tcp-keepalive {{ valkey_tcp_keepalive }}
# =================================================================
# Require password for all operations
requirepass {{ valkey_requirepass }}
requirepass {{ valkey_password }}
# =================================================================
# Memory Management
@@ -127,4 +127,4 @@ client-output-buffer-limit pubsub 32mb 8mb 60
# - Database 3+: Future applications
#
# Connection example:
# redis-cli -h {{ valkey_bind }} -p {{ valkey_port }} -a {{ valkey_requirepass }} -n 1
# valkey-cli -h {{ valkey_bind }} -p {{ valkey_port }} -a {{ valkey_password }} -n 1

View File

@@ -0,0 +1,78 @@
# Valkey Systemd Service
# Generated by rick-infra Valkey role
#
# This service provides a secure, hardened Valkey instance with proper configuration loading
[Unit]
Description=Valkey (Redis-compatible) Key-Value Store
Documentation=https://valkey.io/
After=network.target
Wants=network-online.target
[Service]
Type=notify
User=valkey
Group=valkey
# Core service configuration - ensures config file is loaded
ExecStart=/usr/bin/valkey-server /etc/valkey/valkey.conf --supervised systemd
ExecReload=/bin/kill -USR2 $MAINPID
# Restart configuration
Restart=on-failure
RestartSec=5s
TimeoutStartSec=60
TimeoutStopSec=60
# Runtime directory
RuntimeDirectory=valkey
RuntimeDirectoryMode=755
# Resource limits
LimitNOFILE=10032
# Security hardening
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectSystem=strict
ProtectHome=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
# Network security
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
# Filesystem permissions
ReadWritePaths=/var/lib/valkey
ReadOnlyPaths=/etc/valkey
# System call filtering
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources @obsolete
# Memory and resource limits
MemoryDenyWriteExecute=yes
LockPersonality=yes
# Capabilities (remove all unnecessary capabilities)
CapabilityBoundingSet=
AmbientCapabilities=
# Process isolation
PrivateUsers=yes
RemoveIPC=yes
# Additional security
UMask=0027
# Ensure service stops cleanly
KillMode=mixed
KillSignal=SIGTERM
[Install]
WantedBy=multi-user.target
Alias=redis.service