forked from mtusi2026/mtusi2026lab3
фронт и secure browser session
This commit is contained in:
@@ -16,9 +16,10 @@ type Config struct {
|
||||
HTTPPort string
|
||||
InstanceID string
|
||||
|
||||
SessionTTL time.Duration
|
||||
IdempotencyTTL time.Duration
|
||||
CursorSigningKey string
|
||||
SessionTTL time.Duration
|
||||
IdempotencyTTL time.Duration
|
||||
SessionCookieSecure bool
|
||||
CursorSigningKey string
|
||||
|
||||
DatabaseURL string
|
||||
DatabaseMaxConns int32
|
||||
@@ -60,6 +61,10 @@ func Load() (Config, error) {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
sessionCookieSecure, err := boolFromEnv("SESSION_COOKIE_SECURE", false)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
databaseURL, err := requiredValueOrFile(
|
||||
"DATABASE_URL",
|
||||
"DATABASE_URL_FILE",
|
||||
@@ -181,12 +186,13 @@ func Load() (Config, error) {
|
||||
}
|
||||
|
||||
return Config{
|
||||
HTTPHost: envOrDefault("APP_HOST", "0.0.0.0"),
|
||||
HTTPPort: envOrDefault("APP_PORT", "8080"),
|
||||
InstanceID: instanceID,
|
||||
SessionTTL: sessionTTL,
|
||||
IdempotencyTTL: idempotencyTTL,
|
||||
CursorSigningKey: cursorSigningKey,
|
||||
HTTPHost: envOrDefault("APP_HOST", "0.0.0.0"),
|
||||
HTTPPort: envOrDefault("APP_PORT", "8080"),
|
||||
InstanceID: instanceID,
|
||||
SessionTTL: sessionTTL,
|
||||
IdempotencyTTL: idempotencyTTL,
|
||||
SessionCookieSecure: sessionCookieSecure,
|
||||
CursorSigningKey: cursorSigningKey,
|
||||
|
||||
DatabaseURL: databaseURL,
|
||||
DatabaseMaxConns: databaseMaxConns,
|
||||
@@ -345,6 +351,20 @@ func int32FromEnv(name string, fallback, minimum int32) (int32, error) {
|
||||
return int32(value), nil
|
||||
}
|
||||
|
||||
func boolFromEnv(name string, fallback bool) (bool, error) {
|
||||
raw := strings.TrimSpace(os.Getenv(name))
|
||||
if raw == "" {
|
||||
return fallback, nil
|
||||
}
|
||||
|
||||
value, err := strconv.ParseBool(raw)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("%s must be true or false: %w", name, err)
|
||||
}
|
||||
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func durationFromEnv(name string, fallback time.Duration) (time.Duration, error) {
|
||||
raw := strings.TrimSpace(os.Getenv(name))
|
||||
if raw == "" {
|
||||
|
||||
Reference in New Issue
Block a user