Initial commit of Descrybe v2 without local scratch artifacts.

Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
2026-08-09 22:47:43 +02:00
commit 8580c996c3
1285 changed files with 325780 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package auth
import (
"net/http"
"time"
"github.com/alexedwards/scs/pgxstore"
"github.com/alexedwards/scs/v2"
"github.com/jackc/pgx/v5/pgxpool"
)
func NewSessionManager(pool *pgxpool.Pool, cookieName string, secure bool, idleHours int) *scs.SessionManager {
sm := scs.New()
sm.Store = pgxstore.New(pool)
sm.Lifetime = 7 * 24 * time.Hour
if idleHours <= 0 {
idleHours = 24
}
sm.IdleTimeout = time.Duration(idleHours) * time.Hour
sm.Cookie.Name = cookieName
sm.Cookie.HttpOnly = true
sm.Cookie.Secure = secure
sm.Cookie.SameSite = http.SameSiteLaxMode
sm.Cookie.Path = "/"
return sm
}
const (
SessionUserIDKey = "user_id"
SessionCompanyIDKey = "company_id"
SessionImpersonatorIDKey = "impersonator_id" // non-prod user switch: original admin/demo
SessionVersionKey = "session_version" // must match users.session_version
)