feat(web): allow Redis session URL separate from app DB
Wire session_url through app.auth/listen so sites can store sessions in Redis while keeping Postgres/SQLite for application data. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
410f36f719
commit
981d754133
5 files changed
+24
-5
No files matched your search
@@ -45,6 +45,7 @@ func NewHandler(appBag map[string]any, entryDir string) (http.Handler, error) {
|
||||
}
|
||||
session.Configure(session.Config{
|
||||
DBURL: dbURL,
|
||||
RedisURL: sessionURLOf(appBag),
|
||||
TTLSec: authCfg.sessionTTL,
|
||||
CookieSecure: authCfg.cookieSecure,
|
||||
})
|
||||
@@ -846,6 +847,18 @@ func dbURLOf(appBag map[string]any) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func sessionURLOf(appBag map[string]any) string {
|
||||
if s, ok := appBag["session_url"].(string); ok && s != "" {
|
||||
return s
|
||||
}
|
||||
if auth, ok := appBag["auth"].(map[string]any); ok {
|
||||
if s, ok := auth["session_url"].(string); ok && s != "" {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func resolvePath(p, entryDir string) string {
|
||||
if filepath.IsAbs(p) {
|
||||
return p
|
||||
|
||||
Reference in new issue
Block a user