update production
release-tag / release-image (push) Failing after 1m40s

This commit is contained in:
2026-05-27 03:08:44 +02:00
parent 782f62a66b
commit b747039ec6
13 changed files with 518 additions and 131 deletions
+22 -2
View File
@@ -36,8 +36,27 @@ type Manager struct {
Client *http.Client
}
type contextKey string
const UserIDKey contextKey = "user_id"
func UserID(r *http.Request) string {
if v, ok := r.Context().Value(UserIDKey).(string); ok {
return v
}
return ""
}
func firstEnv(keys ...string) string {
for _, k := range keys {
if v := os.Getenv(k); v != "" {
return v
}
}
return ""
}
func New(ctx context.Context, db *sql.DB) (*Manager, error) {
c := Config{os.Getenv("APP_BASE_URL"), os.Getenv("OIDC_ISSUER"), os.Getenv("OIDC_CLIENT_ID"), os.Getenv("OIDC_CLIENT_SECRET"), os.Getenv("SESSION_SECRET")}
c := Config{firstEnv("APP_BASE_URL", "PUBLIC_URL"), firstEnv("OIDC_ISSUER", "POCKET_ID_ISSUER"), firstEnv("OIDC_CLIENT_ID", "POCKET_ID_CLIENT_ID"), firstEnv("OIDC_CLIENT_SECRET", "POCKET_ID_CLIENT_SECRET"), os.Getenv("SESSION_SECRET")}
if c.SessionSecret == "" {
c.SessionSecret = "dev-secret-change-me"
}
@@ -210,7 +229,8 @@ func (m *Manager) Require(next http.Handler) http.Handler {
http.Redirect(w, r, "/login", 302)
return
}
next.ServeHTTP(w, r)
ctx := context.WithValue(r.Context(), UserIDKey, uid)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
func Logout(w http.ResponseWriter, r *http.Request) {