Skip to content

[3/4] authentication: canonicalize enterprise credential storage - #338151

Merged
TylerLeonhardt merged 6 commits into
mainfrom
tyleonha/ghe-stack-3-credential-storage
Sep 29, 2026
Merged

TylerLeonhardt merged 6 commits into
mainfrom
tyleonha/ghe-stack-3-credential-storage

Conversation

@TylerLeonhardt

@TylerLeonhardt TylerLeonhardt commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Review stack

#338149 (merged) -> #338150 (merged) -> #338151 (canonical credential storage) -> #338080 (multi-host enablement)

This PR targets main; #338080 remains stacked on this branch. The provider lifecycle and core registration buffering are already on main through #338150.

Stack 3/4: Canonical credential storage

Derive enterprise credential keys from normalized instance URIs instead of maintaining a persistent canonical-to-storage registry.

  • Remove github-enterprise.storageKeys, namespace claims, and the host/storage planning layer. No migration marker or replacement bookkeeping key is added.
  • Normalize hostname casing and trailing slashes while preserving scheme, deployment path case, and ports.
  • Locate existing legacy token and Microsoft account-link stores through their existing storage keys, then move the selected data to the canonical credential keys before creating the engine.
  • Preserve native session/account fields and token payloads. Canonical credentials, including signed-out state, remain authoritative.
  • Keep legacy data until destination writes succeed; propagate write/cleanup failures and retry without a completion marker.
  • Recheck canonical credentials around asynchronous legacy reads/copies so a newer sign-in is not overwritten.
  • Keep public GitHub available if enterprise migration fails. Token-only migration does not add a dependency on global-state writes.

This remains a working single-host provider. It adds no plural setting, host picker, host-qualified identities, or workbench changes. Ambiguous legacy aliases require selecting the original URI rather than silently choosing a store.

Validation

Full-suite baseline: f3150bec6a5.

  • 128 GitHub authentication extension tests passed independently on this layer.
  • Coverage includes alias changes, restarts, Microsoft-only consent, canonical sign-out, read-only state for token-only migration, escaped paths, every migration write/cleanup failure, and newer canonical credentials appearing during migration.
  • The stale-canonical-read regression was verified to fail before the fix and pass afterward.
  • Extension compilation, browser-target type checks, scoped lint, hygiene, and diff checks passed.

Tests use fake storage and isolated test profiles; no actual user credentials or settings were modified. The follow-on #338080 uses the same deterministic keys and handles ambiguous legacy HTTP/HTTPS ownership without a persistent registry.

URI helper consolidation

URI-consolidation checkpoint: 8bb82878fe5.

Removed the tiny single-host enterpriseConfiguration.ts module: its URI identity helper and legacy setting constant now live in enterpriseStorage.ts. Hostname lowercasing is left to Uri.toString(); explicit scheme and trailing-slash normalization remain. Added coverage for uppercase schemes, explicit default ports, root paths, repeated trailing slashes, and escaped deployment paths.

Fresh validation for this behavior-preserving follow-up: 51 targeted GitHub Enterprise tests passed, plus extension compilation, browser-target type checking, scoped lint, hygiene, and diff checks. The 128-test full-suite result above is the prior baseline.

Selected canonical-precedence feedback

Current head: 4ee145bdaef.

Canonical tokens and Microsoft account links are authoritative independently. Alias selection is required only for a component still missing from the canonical destination; already-authoritative components can clean up their redundant aliases. Signed-out empty values remain authoritative. Unresolved ambiguity for missing data still fails before mutation.

Added explicit user-info casing coverage for the already-simplified URI helper. Seven migration regression cases were verified failing before the fix and passing afterward. 58 targeted GitHub Enterprise tests passed, with fresh extension compilation, browser-target type checks, scoped lint, hygiene, and diff checks. Earlier full-suite counts above are historical baselines. The migration-only region remains scheduled for removal in 1.144.

@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-2-provider-lifecycle branch from 6ede8ba to 5dd8126 Compare September 26, 2026 22:14
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-3-credential-storage branch from 68a940e to 0325d01 Compare September 26, 2026 22:14
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-3-credential-storage branch from 0325d01 to 33e6ec6 Compare September 27, 2026 05:55
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-2-provider-lifecycle branch from 5dd8126 to 30f2837 Compare September 27, 2026 05:55
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-3-credential-storage branch from 33e6ec6 to b691a97 Compare September 27, 2026 17:27
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-2-provider-lifecycle branch from 30f2837 to 118cd44 Compare September 27, 2026 17:27
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-3-credential-storage branch 4 times, most recently from dbf2f8e to e7260f8 Compare September 28, 2026 23:04
Base automatically changed from tyleonha/ghe-stack-2-provider-lifecycle to main September 28, 2026 23:58
Use deterministic host and storage planning for the existing single enterprise URI. Retain original keychains and Microsoft account links across equivalent URI edits and restarts, reject storage collisions, and leave public GitHub usable when enterprise storage fails.

Co-authored-by: Copilot <[email protected]>
@TylerLeonhardt
TylerLeonhardt force-pushed the tyleonha/ghe-stack-3-credential-storage branch from e7260f8 to 44b817d Compare September 29, 2026 00:10
TylerLeonhardt and others added 2 commits September 28, 2026 23:53
…them

Use a canonical URI-derived credential key and migrate the matching legacy tokens and Microsoft account links before starting the host engine. Keep legacy data until destination writes succeed, preserve canonical sign-out state, and retry incomplete migration without a registry or completion marker.

Co-authored-by: Copilot <[email protected]>
Read the canonical destination after inspecting legacy stores and recheck its token before copying. Cover concurrent canonical writes and assert exactly which credentials survive each failed migration write or cleanup.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 07:16
@TylerLeonhardt TylerLeonhardt changed the title [3/4] authentication: preserve enterprise credential namespaces [3/4] authentication: canonicalize enterprise credential storage Sep 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Migration can reject authoritative canonical credentials, and URI normalization can mutate case-sensitive user-info.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Canonicalizes GitHub Enterprise credential storage and migrates legacy tokens/account links before engine creation.

Changes:

  • Adds deterministic URI-derived storage keys and migration logic.
  • Preserves public GitHub availability during enterprise failures.
  • Adds migration, recovery, normalization, and failure-path tests.
File Description
common/​enterpriseConfiguration.ts Defines URI canonicalization.
common/​enterpriseStorage.ts Migrates legacy credentials.
githubEnterprise.ts Migrates before engine creation.
test/​enterpriseStorage.test.ts Tests migration behavior.
test/​githubEnterprise.test.ts Tests provider lifecycle integration.
test/​extension.test.ts Tests activation and recovery.
test/​testMemento.ts Models key deletion correctly.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 9381d992 Current: 2f3689e0

Changed (2)

sessions/accountMenu/WeeklyLimitOnly/Light
Before After
before after
sessions/accountMenu/FiveHourLimitOnly/Light
Before After
before after

1 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

TylerLeonhardt and others added 3 commits September 29, 2026 09:14
Rely on URI serialization for hostname casing, retain explicit scheme and trailing-slash normalization, and fold the single-host configuration helper into enterpriseStorage. Extend coverage for uppercase schemes, default ports, root paths, repeated slashes and escaped deployment paths.

Co-authored-by: Copilot <[email protected]>
Group temporary migration declarations and functions in a region scheduled for removal in 1.144, four releases after 1.140. Keep permanent URI and credential-key helpers outside the region.

Co-authored-by: Copilot <[email protected]>
Select legacy token and account-link sources only when their canonical component is absent. Clean up aliases for authoritative canonical values without overwriting them, while retaining unresolved sources for missing data. Cover canonical sign-out, concurrent canonical writes, partial migration, cleanup retry, and case-sensitive URI user-info.

Co-authored-by: Copilot <[email protected]>
@TylerLeonhardt
TylerLeonhardt marked this pull request as ready for review September 29, 2026 17:45
@TylerLeonhardt
TylerLeonhardt enabled auto-merge (squash) September 29, 2026 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants