// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial // SPDX-FileCopyrightText: 2025-2026 Christian Galo package config import ( "strings" "github.com/spf13/viper" ) // DefaultDeploymentName is the value the console presents for itself when // no deployment-name is configured — the generic product name, chosen so a // fresh deployment's screenshots and first impressions stay brand-neutral // (openspec ux-honest-surfaces, deployment-identity spec). const DefaultDeploymentName = "Member Console" // DeploymentName returns the configured deployment-name value (the // `deployment-name` key / MC_DEPLOYMENT_NAME), trimmed, falling back to // DefaultDeploymentName when unset. ValidateStart rejects an explicitly // blank override at boot, so a running process never actually hits the // fallback in production; it exists so every caller — including template // render tests that build page data directly, without going through // cmd/start.go's viper.SetDefault — gets a safe, non-blank name. // // Registered as the "deploymentName" template func everywhere operator.html // or a member shell (index.html, billing.html, products.html, error.html) // is parsed, so every shell renders one configured identity instead of a // hardcoded per-deployment brand. func DeploymentName() string { if name := strings.TrimSpace(viper.GetString("deployment-name")); name != "" { return name } return DefaultDeploymentName } // IdPAccountURL returns the identity provider's self-service account // console URL, the destination of the shell's "Identity and Access" control // (chrome-conventions "Session controls live in the account menu"). It is // the `oidc-idp-account-url` key when set; otherwise the issuer URL with // "/account" appended, which is Keycloak's shape. OpenID Connect discovery // defines no account-management URL, so providers other than Keycloak // configure it explicitly (oidc-login "The identity provider's account // console URL is configured"; change acceptance-fixes, 2026-09-02). func IdPAccountURL() string { if u := strings.TrimSpace(viper.GetString("oidc-idp-account-url")); u != "" { return u } return strings.TrimRight(viper.GetString("oidc-idp-issuer-url"), "/") + "/account" } // SupportURL returns the configured `support-url` key (`MC_SUPPORT_URL`), // trimmed, or "" when unset. Already used to attach a contact link to // server-error copy (fedwiki's workflow error messages); the shell's // account menu now also gates its "Get help" control on this value, // rendering the control only when it is non-empty (chrome-conventions // "Session controls live in the account menu on both surfaces", "Get help // appears only with a destination"; change acceptance-fixes, 2026-09-02). func SupportURL() string { return strings.TrimSpace(viper.GetString("support-url")) }