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

feat: Add third-party auth support #999

Merged
merged 6 commits into from
Aug 12, 2024
Merged

feat: Add third-party auth support #999

merged 6 commits into from
Aug 12, 2024

Conversation

dshukertjr
Copy link
Member

What kind of change does this PR introduce?

Adds support for the accessToken option on the Supabase client which can be used to provide a third-party authentication (e.g. Auth0, Clerk, Firebase Auth, ...) access token or ID token to be used instead of Supabase Auth.

When set, supabase.auth.xyz cannot be used and an error will be thrown.

js PR here: supabase/supabase-js#1004

@dshukertjr dshukertjr marked this pull request as draft August 7, 2024 13:52
@dshukertjr dshukertjr marked this pull request as ready for review August 7, 2024 14:35
@dshukertjr dshukertjr requested review from DanMossa, bdlukaa and Vinzent03 and removed request for DanMossa, bdlukaa and Vinzent03 August 9, 2024 01:09
@@ -75,6 +75,7 @@ class Supabase {
PostgrestClientOptions postgrestOptions = const PostgrestClientOptions(),
StorageClientOptions storageOptions = const StorageClientOptions(),
FlutterAuthClientOptions authOptions = const FlutterAuthClientOptions(),
Future<String> Function()? accessToken,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe create a typedef for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I know this is highly opinionated, but I really feel that using typedef generally decreases the readability of the code. Especially since a property named accessToken doesn't sound like a function.

@@ -122,18 +133,30 @@ class SupabaseClient {
},
_httpClient = httpClient,
_isolate = isolate ?? (YAJsonIsolate()..initialize()) {
auth = _initSupabaseAuthClient(
_authInstance = _initSupabaseAuthClient(
Copy link
Collaborator

Choose a reason for hiding this comment

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

When a custom access token is passed, no auth instance should be created, right? From what I see, this is still the case, but just because it's marked as late. I would prefer a clearer structure to ensure no auth instance is created.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can always come back and change the implementation of it. For now, I'm going to merge this PR as this is not really critical.

@dshukertjr dshukertjr merged commit c68d44d into main Aug 12, 2024
6 checks passed
@dshukertjr dshukertjr deleted the feat/accessToken branch August 12, 2024 13:56
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.

3 participants