-
Notifications
You must be signed in to change notification settings - Fork 20
feat: github auth flow and auto-applying discord roles #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…feature/github-login
…nto feature/github-login-db
This pull request introduces 1 alert when merging 4516941 into 1a8f613 - view on LGTM.com new alerts:
|
Co-authored-by: josef <josef.aidt@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this, Emma! 🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Couple minor comments, but no need to block on them. Great work! ✨
|
||
### Creating the App | ||
|
||
1. Go to your GitHub organization, and click **Settings** -> **Developer Settings** -> **GitHub Apps** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want an OAuth App instead of a normal GitHub App?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case we ended up doing a normal App WITH OAuth because we can authenticate the app installation to access organization resources.
if (user.bot) { | ||
return 'This command does not support bots logging in.' | ||
} else return { | ||
content: `${import.meta.env.VITE_HOST}/profile/link`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to send them the OAuth /authorize
link?
Co-authored-by: Dillon Nys <24740863+dnys1@users.noreply.github.com>
Co-authored-by: Dillon Nys <24740863+dnys1@users.noreply.github.com>
This pull request introduces 1 alert when merging 620eea6 into e37a293 - view on LGTM.com new alerts:
|
Issue #, if available:
closes #16
closes #87
Description of changes:
Adds the ability for authenticated Discord users to link their GitHub account.
New Discord command
/login
sends user ephemeral message with a url to link their GitHub account. (currently localhost url)The GitHub login page can also be reached by clicking the Discord user icon then choosing Link GitHub Account
After linking the GitHub account, in
signin
event innext-auth
generates an app token using a the GitHub App credentials, which is used to ping the GitHub api to check for org members and contributors.Discord staff roles are added to users who are members of the AWS Amplify org, and contributor roles to contributors to the Amplify org. If the user already has a Discord staff or contributor role but does not have these credentials on the Amplify GitHub org, the Discord roles are then removed. Most of this is in
src/lib/github/apply-roles
Additionally there is a GitHub org webhook that signals org membership changes, in
webhooks/github-org-membership
. If someone leaves the Amplify org their staff role on Discord will be removed, and if they join the org a staff role will be added.Testing
This change involves the adding about 8 new variables to
.env
, and instructions for generating these can be found inguide.md
(which will need to be integrated into the contribution guide somehow, just here for reference).The Amplify org GitHub App has NOT been installed yet, so some of credentials for this org are still missing. For testing purposes I created a temporary org and GitHub App to test adding staff/contributor roles.
If you want to pull this down to test, you can either create your own org and app installation (instructions in
guide
) or get in touch with me for the for the needed credentials.login-command.mov
You can see that staff and contributor roles are added to my Discord user after linking my GitHub account.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.