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

Add thirdparty Discord provider (OAuth 2.0) #1279

Closed
wants to merge 6 commits into from
Closed

Add thirdparty Discord provider (OAuth 2.0) #1279

wants to merge 6 commits into from

Conversation

plunkettscott
Copy link
Contributor

@plunkettscott plunkettscott commented Jan 7, 2024

Description

This PR adds the Discord OAuth provider in order to support authentication via Discord.

Tests

I have tested the OAuth flow using Discord and all features worked as expected.

Implementation

I've copied the existing Google provider, however, Discord avatar URLs have to be built based on a returned hash. I implemented this functionality on the Discord provider itself even though it does not rely on any other provider functionality in order to keep the top-level API footprint of the package low.

In addition, I've also setup the Discord icon in the frontend elements and updated the configuration documentation to reflect the new third_party.providers.discord config object.

Todos

The documentation site still needs to be updated. I didn't update the docs/ within this repository as it doesn't seem to be the currently active documentation site. If I need to update the docs within this repository, please let me know.

@FlxMgdnz FlxMgdnz requested review from shentschel and lfleischmann and removed request for shentschel January 8, 2024 21:10
@lfleischmann
Copy link
Member

lfleischmann commented Jan 10, 2024

Would you mind adding some tests? Thirdparty stuff is currently mainly tested through interaction with the thirdparty handler endpoints, i.e. the auth and callback endpoints. See here and here for examples.

Otherwise: looks good and does work, thanks!

@plunkettscott
Copy link
Contributor Author

I've generated the JSON Schema and added tests. Apologies on the lack of tests at first, I didn't see those tests in the handler package.

s.Equal("discord", identity.ProviderName)
s.Equal("discord_abcde", identity.ProviderID)

logs, lerr := s.Storage.GetAuditLogPersister().List(0, 0, nil, nil, []string{"thirdparty_signin_succeeded"}, user.ID.String(), "", "", "")
Copy link
Member

@lfleischmann lfleischmann Jan 11, 2024

Choose a reason for hiding this comment

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

This one still counts as a sign up because no user with an appropriate identity exists. Hence the logs are empty (because it looks for an event with a different key, i.e. signin instead of signup) and the test fails. To accomplish this you would need an existing user.

The test suite runs a postgres container and uses fixtures to populate the database with data for the test. So, in order for this to work you'd have to add an existing user with the required data (see the link above for examples).

Copy link
Member

Choose a reason for hiding this comment

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

Hi @plunkettscott, what's the status on this? We're about to make some slight changes to the third party stuff, which most likely also affects some of the tests. Would be great if we could merge this PR before merging the third party changes so that you don't have to bother with any more changes.

@lfleischmann
Copy link
Member

Closing in favour of #1353

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

Successfully merging this pull request may close these issues.

2 participants