feat(admin): support authenticated Redis, and point at the external server
Server Deploy / deploy (push) Successful in 2m14s

Adds REDIS_USERNAME and REDIS_PASSWORD. Both are optional, so an
unauthenticated instance still works unchanged. Redis 6+ ACL auth takes
both; a legacy requirepass instance takes the password with an empty
username, which is what go-redis needs to send single-argument AUTH.

Admin now defaults to the external Redis at 10.10.10.2:6379 rather than the
compose-local one, and no longer declares depends_on: redis -- it is not
starting that container any more. The base stack keeps its own Redis for
`server`, which still has no auth support.

Also fixes SMTP_PASSWORD in the admin block: it read `$SMTP_PASSWORD:-}`
rather than `${SMTP_PASSWORD:-}`, which appended a literal `:-}` to the
password and would have failed SMTP auth at the first verification email.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
mrhid6
2026-07-25 19:50:19 +01:00
co-authored by Claude Opus 5
parent 946a748038
commit 58c37bf81b
4 changed files with 40 additions and 27 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ func main() {
log.Println("warning: SMTP not configured; verification and licence emails will fail")
}
auth.InitRedis(cfg.RedisAddr)
auth.InitRedis(cfg.RedisAddr, cfg.RedisUsername, cfg.RedisPassword)
pingCtx, pingCancel := context.WithTimeout(context.Background(), 10*time.Second)
if err := auth.Ping(pingCtx); err != nil {
pingCancel()
+12 -1
View File
@@ -30,7 +30,18 @@ type Session struct {
var rdb *redis.Client
func InitRedis(addr string) { rdb = redis.NewClient(&redis.Options{Addr: addr}) }
// InitRedis connects the session store.
//
// Username and password may both be empty for an unauthenticated instance. For
// a legacy `requirepass` Redis, pass the password with an empty username —
// go-redis then sends AUTH with one argument instead of two.
func InitRedis(addr, username, password string) {
rdb = redis.NewClient(&redis.Options{
Addr: addr,
Username: username,
Password: password,
})
}
func Ping(ctx context.Context) error { return rdb.Ping(ctx).Err() }
+7
View File
@@ -18,6 +18,8 @@ type Config struct {
ControlMongoURI string
ControlDBName string
RedisAddr string
RedisUsername string
RedisPassword string
SigningKey string
PublicURL string
AllowedOrigins []string
@@ -54,6 +56,11 @@ func Load() (Config, error) {
AdminMongoURI: os.Getenv("ADMIN_MONGO_URI"),
ControlMongoURI: os.Getenv("CONTROL_MONGO_URI"),
RedisAddr: os.Getenv("REDIS_ADDR"),
// Optional: an unauthenticated Redis needs neither. Redis 6+ ACL auth
// takes both; a legacy `requirepass` instance takes the password alone
// and must leave the username empty.
RedisUsername: os.Getenv("REDIS_USERNAME"),
RedisPassword: os.Getenv("REDIS_PASSWORD"),
SigningKey: os.Getenv("LICENSE_SIGNING_KEY"),
PublicURL: strings.TrimSuffix(os.Getenv("PUBLIC_URL"), "/"),
TrustProxy: strings.EqualFold(os.Getenv("TRUST_PROXY"), "true"),