Skip to content
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

Updated Discord Authentication Module to allow optionally filtering based on Server Roles. #6323

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

TomDakan
Copy link

@TomDakan TomDakan commented Apr 5, 2023

Updated Discord Authentication Module to allow optionally filtering based on Server Roles. Added custom authentication error message. Added Discord-Oauth2 to package.json. Discord-Oauth2 is used to fetch role data from the specified server in module/discord/authentication.js

…ased on Server Roles.

Updated Discord Authentication Module to allow optionally filtering based on Server Roles. Added custom authentication error message. Added Discord-Oauth2 to package. Discord-Oauth2 is used to fetch role data from the specified server.
@auto-assign auto-assign bot requested a review from NGPixel April 5, 2023 19:47
@TomDakan TomDakan marked this pull request as draft April 7, 2023 15:47
@TomDakan
Copy link
Author

TomDakan commented Apr 7, 2023

Still getting familiar with vs dev containers and working with git. Discovered that some of my changes were reverted at some point, so I need to recover them and retest.

@tboba
Copy link

tboba commented Sep 25, 2023

Hey @TomDakan, thank you for opening this PR! ❤️ If you're still interested in this change, are you planning to finish this draft? I'm willing to use this feature and I'm interested in finishing those changes if it's not possible for you to finish it at the moment 🙏

@TomDakan
Copy link
Author

@tboba hey, i've been using it for the last few months and it's been working fine, but I had to do a few things that wouldn't be best practice for the actual PR to get the dependencies included that I needed. I'll try to look at my repo in the next few days and see if I can clean it up to produce a finalized PR.

@tboba
Copy link

tboba commented Sep 25, 2023

@TomDakan sure! If you would like to I can do a code review for you in about an hour 👍

Also, how are you using this change right now? Are you making your own patch and building Wiki.js from source with it, or doing it in other way? I'm just asking, because I can't find any guide how to build Wiki.js from source 🥲

@TomDakan
Copy link
Author

@tboba the "simplest" way I found to do it was to create another volume and bind it into the authentication module directory as a new custom module. I remember trying to figure out how to build a fresh production droplet with my changes to the generic discord auth module, and not being able to figure it out in a reasonable amount of time. I found the dev environment very complicated. There is info on how to build a production build at the bottom of this article: https://docs.requarks.io/dev that you might find useful if you haven't read it yet.

So your docker command would be something like:
docker run -e LETSENCRYPT_DOMAIN=wiki.domainname.com -e LETSENCRYPT_EMAIL=[email protected] -e SSL_ACTIVE=1 -e DB_TYPE=postgres -e DB_HOST=db -e DB_PORT=5432 -e DB_PASS_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -e DB_USER=wiki -e DB_NAME=wiki -e UPGRADE_COMPANION=1 --restart=unless-stopped -h wiki --mount type=bind,source=/mnt/volume_sfo3_01/discord_custom,target=/wiki/server/modules/authentication/discordCustom --network=wikinet -p 80:3000 -p 443:3443 ghcr.io/requarks/wiki:2

@TomDakan
Copy link
Author

Also, I think all of my changes are committed now. I don't have time to test it today, but hopefully it will get you going.

@tboba
Copy link

tboba commented Sep 25, 2023

Thanks! 😄 Also, let me leave a couple of comments about proposed changes, so it could land on the main successfully ✌️

Copy link

@tboba tboba left a comment

Choose a reason for hiding this comment

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

As I said, just a couple of comments from me. Again, great job with this! ❤️

.gitignore Outdated Show resolved Hide resolved
server/modules/authentication/discord/authentication.js Outdated Show resolved Hide resolved
server/modules/authentication/discord/authentication.js Outdated Show resolved Hide resolved
server/modules/authentication/discord/authentication.js Outdated Show resolved Hide resolved
server/modules/authentication/discord/package.json Outdated Show resolved Hide resolved
server/modules/authentication/discord/definition.yml Outdated Show resolved Hide resolved
@TomDakan
Copy link
Author

@tboba also, I think I got all your changes integrated correctly. Let me know if i screwed something up. Particularly moving the intitialization of the DiscorOauth2 object outside of the initialization of the passport strategy.

@TomDakan
Copy link
Author

Also, thanks for the review. I don't spend much time working in javascript.

Copy link

@tboba tboba left a comment

Choose a reason for hiding this comment

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

Just for cleanup purposes, I've just left a couple of comments what you should also remove 👍

server/modules/authentication/discord/authentication.js Outdated Show resolved Hide resolved
server/modules/authentication/discord/authentication.js Outdated Show resolved Hide resolved
server/modules/authentication/discord/authentication.js Outdated Show resolved Hide resolved
Co-authored-by: Tymoteusz Boba <[email protected]>
@TomDakan TomDakan marked this pull request as ready for review September 26, 2023 21:52
@tboba
Copy link

tboba commented Sep 26, 2023

Thanks for completing this draft @TomDakan ❤️ @NGPixel can you please take a look on those changes in your free time? 🙏

@NGPixel
Copy link
Member

NGPixel commented Sep 26, 2023

You shouldn't have a package.json in the discord module folder, as you're submitting a PR to make it part of the official repo. The per-module package.json is only for custom modules that are not part of Wiki.js itself.

@TomDakan
Copy link
Author

TomDakan commented Sep 26, 2023

@NGPixel ok, I'll remove it. Does that mean I should modify the main package.json to include the dependency?
Nevermind, I forgot that I already had.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants