feature(eng-5200): support domain in .infisical.json and INFISICAL_DOMAIN env var#256
Conversation
…L_DOMAIN env var - Add `domain` field to .infisical.json, resolved when --domain is not passed - Add INFISICAL_DOMAIN env var; keep INFISICAL_API_URL as legacy alias - Precedence: --domain flag > INFISICAL_DOMAIN/INFISICAL_API_URL env > .infisical.json domain > default - Centralize env precedence in util.DomainEnvNames, used by GetEnvDomain and GetCmdFlagOrEnvWithDefaultValue - Move domain resolution to PersistentPreRun so the parsed flag is honored - Warn and ignore a malformed domain field; print the source when read from .infisical.json - Table-driven tests for domain parsing and env precedence
|
💬 Discussion in Slack: #pr-review-cli-256-feature-eng-5200-support-domain-in-infisical-json-and-infisica Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| packages/cmd/root.go | Adds resolveDomain to centralize domain precedence (flag > env > .infisical.json > default) and moves resolution to PersistentPreRun; introduces SSRF risk where a file-controlled domain silently redirects CLI traffic including auth tokens. |
| packages/cmd/login_status.go | Switches domain env check to GetEnvDomain() but the guard for --token still fails when the domain is resolved from .infisical.json, causing a false error for a valid use-case. |
| packages/util/helper.go | Adds DomainEnvNames slice and GetEnvDomain() helper that centralises env-var precedence for domain resolution; straightforward and well-tested. |
| packages/util/constants.go | Renames INFISICAL_API_URL_ENV_NAME to INFISICAL_DOMAIN_ENV_NAME and retains LEGACY_INFISICAL_API_URL_ENV_NAME for backward compatibility; clean. |
| packages/util/config_test.go | New table-driven tests cover domain parsing from file and env-var precedence; good coverage of edge cases including blank-env fallthrough. |
| packages/models/cli.go | Adds Domain field (omitempty) to WorkspaceConfigFile; non-breaking schema addition. |
| packages/cmd/bootstrap.go | Switches to GetCmdFlagOrEnvWithDefaultValue with DomainEnvNames; consistent with the rest of the refactor. |
| packages/cmd/kmip.go | Updates env-names slice to DomainEnvNames; simple one-line deduplication change. |
| packages/cmd/login.go | Updates info message text to reference INFISICAL_DOMAIN and renames the prompt label; cosmetic. |
| packages/util/testdata/infisical-with-domain.json | New test fixture for domain-field parsing. |
Reviews (1): Last reviewed commit: "feature(eng-5200): add domain support in..." | Re-trigger Greptile
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
- login status --token now accepts a domain from .infisical.json (was a false error) - Always warn (even under --silent) when the domain comes from .infisical.json, since a committed config could redirect requests and credentials
maidul98
left a comment
There was a problem hiding this comment.
we need to update the docs at https://infisical.com/docs
Description 📣
Adds a
domainfield to.infisical.jsonand a newINFISICAL_DOMAINenvironment variable so the Infisical instance can be configured per-project, not just via--domainor the env var.domainfield to.infisical.json, resolved when--domainis not passedINFISICAL_DOMAINenv var; keepINFISICAL_API_URLworking as a legacy alias--domainflag >INFISICAL_DOMAIN(or legacyINFISICAL_API_URL) env >.infisical.jsondomain> defaultutil.DomainEnvNames, consumed byGetEnvDomainandGetCmdFlagOrEnvWithDefaultValue(no duplicated ordering acrosskmip/bootstrap)PersistentPreRunso the parsed--domainflag is reliably honored (it isn't parsed yet ininit())domain(must start withhttp:///https://); print an[INFO]line when the domain comes from.infisical.jsonNet-new work; takes over the intent of community PR #242 but reworks it (field named
domainnotapiUrl, sinceapiUrlnever shipped).Docs at
/docs/cli/project-configlive in the monorepo and will follow up separately.Type ✨
Tests 🛠️
Table-driven unit tests for domain parsing and env precedence:
Verified end-to-end against the real binary that the API request URL resolves correctly for flag > env >
.infisical.json, that a malformeddomainwarns and is ignored, that--silentsuppresses the info line, and that the legacyINFISICAL_API_URLenv var still works.