Simplified OAuth, SSO, Native Auth in separate module - #1291
Simplified OAuth, SSO, Native Auth in separate module#1291jan-tennert wants to merge 17 commits into
Conversation
ab4b9c7 to
860affa
Compare
|
I wonder now that we have |
Do you mean what happens to compose auth?
|
Interesting. This would make the integration more convinient 👍 |
|
cc @grdsdev |
| } | ||
| } | ||
| allTargets() | ||
| /* swiftPMDependencies { |
There was a problem hiding this comment.
Nice one @jan-tennert 👍. I was about to ask if we can replace spm4kmp from the plugins to this. Let me know if you need some iOS testing
There was a problem hiding this comment.
Yea I'll probably leave that one out of this PR. Also not completely sure how that swift pm integration works with publishing yet
What kind of change does this PR introduce?
Feature, the target branch is probably going to change, since this PR would be included in 4.0
What is the current behavior?
auth-ktdoes two things: mirroring the JS SDK in terms of API methods but also providing platform specific implementations for stuff like OAuth, Deeplinks, etc. This approach worked, but is now getting even more bloated with the addition of passkeys and a proposed API in #1283 (which is now included in this PR). Also, people not using these platform-specific implementation, still have the needed dependencies included, which is not ideal.What is the new behavior?
Everything below is work-in-progress. Note that if this PR goes through with the proposed changes,
compose-authmight get obsolete and removed in 4.0Base changes
auth-ktreally only provides:(1) Methods to call the Supabase API (now with split
auth.signInWithPassword(),auth.signInWithOtp(),auth.signInWithIdToken(), etc for SDK parity)(2) Handle session management, if not disabled (this PR also makes all API related methods return a
UserSessionand also an option to disable the session importing into memory, so it is even easier for server-side applications)auth-nativeprovides:The only thing you have to do:
install(Auth.withNative())Note that the base
auth-ktdoesn't have any of these methods, since they would need platform specific dependencies. If users decide to make their own implementation they can just useauth.getOAuthUrl(...)andauth.passkeysNew syntax
Sign in [With Email() or Phone()]
Sign in with OTP
Sign up [with Email() or Phone()]
Sign in with ID Token
Native-Auth module:
Sign in with OAuth
Linking identity
Sign in with SSO
Native Google Auth (or OAuth as a fallback)
Native Apple Auth (or OAuth as a fallback)
Android / iOS OAuth related changes
Android
On Android, the only thing you have to do now is set the app scheme and optionally the host in the build configuration:
android { defaultConfig { manifestPlaceholders["supabaseAuthScheme"] = "myScheme" // optional: manifestPlaceholders["supabaseAuthHost"] = "myHost" } }The library will take care of everything else. No more
handleDeeplinks()or something similar. The library will also catch magic links.iOS
On iOS,
ASWebAuthenticationSessionis now used for OAuth, fixing #1253 and also making the process more iOS idiomatic. For magic links / deeplinks from outside the app, you still have to usehandleDeeplinks(), but with a new method for better visbility in Swift (SupabaseDeeplinkHandlerKt.handleDeeplinks(). The scheme entry inPList.infois still required as is setting the scheme in the config:Todos:
Google Auth on iOSWill probably not happen in this PR, waiting for SwiftPM getting more stable