Repository navigation
Let branch previews sign in with Discord through dev - #154
Merged
Merged
Conversation
Discord only returns players to registered callbacks, so a preview at <slug>.tfminecraft.net could not sign anyone in. Previews now send the browser to dev, which signs the player in (or uses its existing session) and returns them with a single-use, 120-second ticket. The preview redeems it with dev for the Discord identity, website role and guild check, then opens its own session. Previews hold no Discord secret. Dev needs PREVIEW_SIGN_IN_DOMAIN=tfminecraft.net; preview images get SIGN_IN_SITE=https://dev.tfminecraft.net at build time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Drop preview start and callback queries from access logs, so a logged ticket cannot be redeemed by someone reading the logs. - When dev's bot cannot refresh a guild check over 15 minutes old, sign in with Discord again instead of handing the preview a stale check that linking would refuse, in a loop. - Refuse malformed preview origins instead of failing with a 500. - Say in the Preview summary that sign-in goes through dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"I've joined, check again" on a preview signs in through dev again. With dev's bot unable to answer, dev handed back the recent "not a member" check, so the button did nothing for up to 15 minutes. A preview that already has a session now asks dev for a recheck, and dev then signs in with Discord once (the saved return drops the recheck, so it ends). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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.
Branch previews (
<slug>.tfminecraft.net) could not sign anyone in: Discord only returns players to registered callbacks, and a new branch name never is one. Previews now sign in through dev, the way OpenFront's branch sites all useapi.openfront.dev.How it works
/auth/discord/startputs a random state in its state cookie and sends the browser to dev's/api/auth/preview/startwith the state, its origin and the return path.https://<slug>.<PREVIEW_SIGN_IN_DOMAIN>origins with an unreserved slug. Without a dev session it signs the player in with Discord first; the callback brings them back to the same route./api/auth/preview/callback./api/auth/preview/redeem, which deletes the ticket and returns the Discord identity, website role and guild check.A player already signed in on dev goes straight through without Discord. Previews never hold the Discord secret or a dev session, and anything done there stays in the preview's copy of dev's data (the LuckPerms bridge, Patreon, CoreProtect and the Discord bot are all off on previews).
Settings
PREVIEW_SIGN_IN_DOMAIN=tfminecraft.netinbackend/.env(added before this deploys).SIGN_IN_SITE=https://dev.tfminecraft.net, baked into the preview backend image by the Preview workflow. Empty everywhere else.No frontend changes: the sign-in button already points at the site's own
/api/auth/discord/start.Testing
src/auth/test_preview_sign_in.py: 54 tests covering allowed preview origins, the preview and dev halves of the flow, single use, expiry, site binding, odd answers from dev and dev being down.pytest src/auth src/api/test_prod_guard.py: all pass.Docs: TF-Minecraft/Docs#123.
🤖 Generated with Claude Code