package platform import ( "errors" "net/url" "strings" "time" ) type Config struct { Brand string Address string PublicURL string DataFile string MasterKey string BootstrapUsername string BootstrapPassword string BootstrapName string AdminAPIToken string SessionTTL time.Duration DefaultLeaseTTL time.Duration MaxLeaseTTL time.Duration SecureCookies bool } func (c *Config) normalize() error { if strings.TrimSpace(c.Brand) == "" { c.Brand = "License Platform" } if strings.TrimSpace(c.Address) == "" { c.Address = ":8091" } c.PublicURL = strings.TrimRight(strings.TrimSpace(c.PublicURL), "/") if c.PublicURL == "" { return errors.New("LICENSE_PUBLIC_URL is required") } parsed, err := url.Parse(c.PublicURL) if err != nil || parsed.Host == "" || (parsed.Scheme != "http" && parsed.Scheme != "https") { return errors.New("LICENSE_PUBLIC_URL must be an absolute HTTP(S) URL") } if token := strings.TrimSpace(c.AdminAPIToken); token != "" && len(token) < 32 { return errors.New("LICENSE_ADMIN_API_TOKEN must contain at least 32 characters when configured") } if c.SessionTTL <= 0 { c.SessionTTL = 12 * time.Hour } if c.DefaultLeaseTTL <= 0 { c.DefaultLeaseTTL = time.Hour } if c.MaxLeaseTTL <= 0 { c.MaxLeaseTTL = 24 * time.Hour } if parsed.Scheme == "https" { c.SecureCookies = true } return nil }