Added OAuth-Based Discord Account Integration (Mirror)#62
Merged
Conversation
* feat: add discord account integration feature * feat: add discord account integration feature * docs: add docs * chore: applied suggestion * test: add some config test coverage
Port the Discord account linking feature from wargame: backend OAuth2 flow, discord_connections persistence, /api/discord/* endpoints, the invite-bot client, migrations, docs, and config. Adds scripts/sync-invite-bot.sh to sync the invite-bot subtree from wargame. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
yulmwu
commented
Jun 25, 2026
yulmwu
left a comment
Member
Author
There was a problem hiding this comment.
This PR is a mirror of the PR specified in the description. Since SMCTF and N4U Wargame share nearly identical codebases, we will merge it immediately without performing additional code reviews on the already verified code.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
This PR introduces Discord account integration using OAuth. Once a user links their Discord account, they are automatically joined to a designated Discord server and assigned a role.
All Discord interactions are handled by a separate service independent of the main backend. The backend is responsible only for managing OAuth clients and storing account-linking information. The overall flow is shown below.
The following backend environment variables have been added:
DISCORD_CLIENT_IDandDISCORD_CLIENT_SECRETcan be obtained from the Discord Developer Portal. You must also configure the corresponding Redirect URI.In addition,
DISCORD_BOT_SECRETmust match the value used by the Invite Bot/Server. The following environment variables have been added for the Invite Bot/Server:Likewise, the bot token, guild ID, and role ID should be obtained from the Discord Developer Portal and configured appropriately for your environment.
Warning
The backend server and the Invite Bot/Server are intentionally separated due to bot sharding concerns. The current implementation was not designed with a general distributed environment in mind, so the bot server should be deployed as a separate single instance. This architecture may be improved in the future.
For more details, please refer to the updated source code and documentation.