feat(auth): block prod-key sign-in on staging homeserver deploys - #2194
Open
infin1t3 wants to merge 1 commit into
Open
feat(auth): block prod-key sign-in on staging homeserver deploys#2194infin1t3 wants to merge 1 commit into
infin1t3 wants to merge 1 commit into
Conversation
Contributor
Greptile SummaryThis PR adds staging homeserver checks to auth restore and sign-in flows. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| src/config/network.ts | Adds canonical staging homeserver detection from runtime config. |
| src/core/services/homeserver/homeserver.ts | Adds PKARR homeserver validation before staging sign-in and restore checks. |
| src/core/application/auth/auth.ts | Checks restored sessions against the staging homeserver guard and avoids retrying terminal environment errors. |
| src/core/controllers/auth/auth.ts | Cleans local auth state and rethrows wrong-environment errors for UI feedback. |
| src/hooks/useAuthUrl/useAuthUrl.tsx | Shows the wrong-environment Ring approval toast and expires the auth URL state. |
| src/providers/RouteGuardProvider/RouteGuardProvider.tsx | Shows the wrong-environment persisted-restore toast from the route guard. |
| src/components/organisms/DialogRestoreRecoveryPhrase/DialogRestoreRecoveryPhrase.tsx | Shows the wrong-environment recovery phrase restore toast. |
| src/components/organisms/DialogRestoreEncryptedFile/DialogRestoreEncryptedFile.tsx | Shows the wrong-environment encrypted-file restore toast. |
Reviews (5): Last reviewed commit: "fix(auth): fail closed on staging homese..." | Re-trigger Greptile
Contributor
🚀 Preview DeploymentURL: https://pubky-app-pr-2194-fzxmjul7ya-oa.a.run.app
|
infin1t3
marked this pull request as draft
July 14, 2026 12:37
infin1t3
marked this pull request as ready for review
July 16, 2026 11:11
Collaborator
Author
|
@greptileai review |
Reject mnemonic, encrypted-file, Pubky Ring, and session-restore auth
when the key's PKARR homeserver does not match a staging deploy:
- Declare deploy identity via a required PUBKY_RUNTIME_ENV
("production" | "staging") runtime value and drive
isStagingHomeserverDeploy() from it, so config drift can never
silently disable the guard. PR previews, the CI smoke test, and local
dev declare theirs in-repo; deployed configs fail loudly at boot when
it is missing.
- Fail closed on staging: a mismatched, absent, or unresolvable PKARR
record blocks sign-in and never republishes the record. Outside
staging, the sign-in self-heal republishes only a provably absent
record - a failed lookup now propagates instead of force-overwriting
a record that may point at another homeserver.
- Enforce the same check when restoring a persisted session: transient
lookup failures retry like any other restore failure, and definitive
mismatches clean up local state, surface a wrong-environment toast,
and sign the rejected session out of its own homeserver (also on the
Ring path) instead of leaving it dangling.
- Show the rejection toast across both restore dialogs and the Ring QR
flow (expiring the stale auth URL), localized in all nine locales.
Closes #2126
infin1t3
force-pushed
the
feat/2126-prevent-prod-signin-staging
branch
from
August 5, 2026 15:22
c530ee6 to
90602c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reject mnemonic, encrypted-file, Ring, and restore when PKARR homeserver does not match the staging deploy; show a clear error toast and avoid republishing mismatched keys.
Resolves #2126