Skip to content

draft: Refactor OAuth Social Providers - #273

Draft
UserNobody14 wants to merge 8 commits into
trailbaseio:devfrom
UserNobody14:configurablescopes
Draft

draft: Refactor OAuth Social Providers#273
UserNobody14 wants to merge 8 commits into
trailbaseio:devfrom
UserNobody14:configurablescopes

Conversation

@UserNobody14

Copy link
Copy Markdown
Contributor

Refactored the repetitive oauth provider code into a series of handy flexible traits, and added tests for the many different quirks of the providers.

I also believe this is a solution to #215, allowing more configurable scopes to be entered, and eliminating email requirements for providers that may not furnish them for one reason or another.

Looking at ways to reduce the line count on this one, i still feel its a bit repetitive.

@ignatz
ignatz changed the base branch from main to dev August 3, 2026 11:28
@ignatz
ignatz force-pushed the dev branch 5 times, most recently from 771ec79 to 0c6e85b Compare August 3, 2026 16:55
@ignatz
ignatz force-pushed the dev branch 3 times, most recently from 4e647cb to b5413f6 Compare August 4, 2026 15:57
@ignatz

ignatz commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Had a first skim. Looks promising. Never loved the verbosity, so pulling in a second layer for providers that can remain mostly declarative makes a lot of sense 👍

My only concern with the OAuth code in general is that it's hard to impossible to test :/. Did you have the chance to test a one or more providers? 🙏

EDIT: Are you still iterating or is this good to go?

@UserNobody14

Copy link
Copy Markdown
Contributor Author

Sorry, wound up caught up in some personal stuff. this is good to go as far as tests and all, but idk, i still feel like its not quite right. Maybe just perfectionism

ignatz added a commit that referenced this pull request Aug 19, 2026
ignatz added a commit that referenced this pull request Aug 19, 2026
…providers to not return an email if the configured `UserIdentifier` policy allows it, and allow social OAuth providers to adjust their scope based on policy.

This is based on #273, plus policy enforcement, plus dependent scoping. Thanks @UserNobody14 🙏
ignatz added a commit that referenced this pull request Aug 19, 2026
…ider.

This is mostly a verbatim extraction from #273 authored by @UserNobody14. Only the UI description was updated. Thanks!

Co-Authored-By: UserNobody14 <zqhlweic4ri8@opayq.com>
@ignatz

ignatz commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

FTR: I started upstreaming the most critical changes proposed here. There's a lot going on and I have a hard time wrapping my head around all of them at once (me problem) while ensuring the behavior doesn't change :)

What happened:

  • I first tidied up the base trait. The plan was to improve the baseline and in principle allow for golden tests to make sure the behavior doesn't change (though I was to lazy to write tests for all providers).
  • Then I pulled out the configurable scopes proposed here. I made it so that OAuthUser can handle optional emails (I see the intent, maybe got lost in the chain?) and policy enforcement.
  • Also added the ability for Social OAuth provider to scope down based on UserIdentifier policy.
  • Added your Admin UI changes

🙏

IUC, the only thing still missing (probably the lowest priority) is to make "simple" Social providers less verbose by having a shared parametrized implementation. I'll probably also look into this but in due time.

@ignatz

ignatz commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Update: I simplified many of the providers very much inspired by your proposal incorporating all the other changes (conditional scopes, simplified base trait). It's not quite declarative and I'm sure lines could be saved but it's pretty thin on abstractions and w/ scopes being more conditional, this feels like a reasonable trade-off: https://github.com/trailbaseio/trailbase/blob/dev/crates/core/src/auth/oauth/providers/gitlab.rs

This was some of the most finicky code, thanks for stepping on my toes and this awesome PR 🙏

@ignatz
ignatz force-pushed the dev branch 5 times, most recently from 3432fa3 to 2236834 Compare August 21, 2026 12:16
@ignatz
ignatz force-pushed the dev branch 6 times, most recently from 8c38ebb to 6fcf273 Compare August 28, 2026 12:02
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.

2 participants