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

Added discord provider #2113

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Added discord provider #2113

wants to merge 5 commits into from

Conversation

draeron
Copy link

@draeron draeron commented May 10, 2023

Enable discord provider with filtering based on guilds membership.

You can use both structured Alpha configuration or --allowed-group options.

@draeron draeron requested a review from a team as a code owner May 10, 2023 03:52
@ronaldmiranda
Copy link

+1

@tuunit
Copy link
Member

tuunit commented Aug 22, 2023

Hi @draeron, I'll have to read some of the discord documentation first before i review this. I'll try to do it next week.

@draeron
Copy link
Author

draeron commented Aug 22, 2023

i have updated my fork with the latest master

@tuunit
Copy link
Member

tuunit commented Sep 12, 2023

Hi @draeron, sorry for the delay. Due to the latest release and some bugfixes with higher priority I wasn't able to look into your implementation yet. Please do another update / rebase of your PR and add a CHANGELOG entry :) I'll do my best to test your provider implementation this week and give it a first code review.

@tuunit tuunit added this to the v8.0.0 milestone Sep 13, 2023
Copy link
Member

@tuunit tuunit left a comment

Choose a reason for hiding this comment

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

I'm missing the test suite for the provider. I tested the discord integration and went through the API documentation. Unfortunately, the group / guild restriction doesn't seem to work.

}

for _, guild := range guilds {
s.Groups = append(s.Groups, guild.ID)
Copy link
Member

Choose a reason for hiding this comment

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

guild ID are of type snowflake. I would suggest we add another flag for the discord provider to allow groups to be returned either as snowflake or the guild name

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +102 to +103
// Avatar string `json:"avatar"`
// Flags int `json:"flags"`
Copy link
Member

Choose a reason for hiding this comment

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

please remove

Do().
UnmarshalInto(&guilds)
if err != nil {
return nil, fmt.Errorf("error getting user's guilds info: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("error getting user's guilds info: %v", err)
return nil, fmt.Errorf("error getting user's guilds info: %w", err)

https://go.dev/blog/go1.13-errors

validateURL: discordDefaultValidateURL,
scope: discordDefaultScope,
})
p.setAllowedGroups(opts.Guilds)
Copy link
Member

Choose a reason for hiding this comment

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

This line is a problem with the legacy --allowed-group flag or allowed_groups config field as it will always overwrite the set values with an empty map map[string]struct {} []

Copy link
Member

Choose a reason for hiding this comment

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

unfortunately, you will have to add legacy support

Choose a reason for hiding this comment

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

Can confirm that legacy support is broken right now. --allowed-group doesn't work

@tuunit
Copy link
Member

tuunit commented Sep 13, 2023

Hi @draeron,

if you want you can continue working on this and/or you give me collaborator access on your repo and i can work on it as well.

Following major todos:

  • Add the option to use guild / server names instead of the id
  • Add full legacy support including conversion logic
  • Add full test suite for all methods of the provider
  • Full documentation for the new provider

@ENG3PLabs
Copy link

I'd also like to contribute. I got it running on my end and would be happy to share what I did plus some additional features like optional email scope (so people don't get scared that an app asks for their email even if it doesn't need it) and Discord role check on a server.

If you could add me as a collaborator, I'd love to push my changes to a feature-branch for review @draeron.

@thecodeassassin
Copy link

thecodeassassin commented Jan 25, 2024

@draeron any chance to update this PR so it meets all the requirements? I built a custom docker image for this now, would be fantastic if this can be merged eventually.

Copy link
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions bot added the Stale label Mar 28, 2024
@github-actions github-actions bot closed this Apr 5, 2024
@kvanzuijlen kvanzuijlen reopened this Apr 5, 2024
@kvanzuijlen kvanzuijlen removed the Stale label Apr 5, 2024
@tuunit
Copy link
Member

tuunit commented Apr 5, 2024

Damn I totally forgot extending and testing this one

@draeron
Copy link
Author

draeron commented Apr 5, 2024

i think this pull request has drifted too much from the master branch, imho it would need to be redone completely

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

Successfully merging this pull request may close these issues.

None yet

6 participants