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

Enhancement ComposeAuth #241

Merged
merged 103 commits into from
Aug 8, 2023

Conversation

temk0
Copy link
Contributor

@temk0 temk0 commented Jul 26, 2023

What kind of change does this PR introduce?

This PR introduce Compose Multiplatform as a approach to Native Login for the Feature Request

What is the current behavior?

Developer relaying on custom integrations of native login with GoTrue-kt

What is the new behavior?

This Module (or modules) will provide an approach where developer can use a provided composable for handling native login

// init Module
    val supabaseClient = createSupabaseClient(
        "supabase-url",
        "supabase-key"
    ) {
        install(GoTrue) {/* your GoTrue config */ }
        install(ComposeAuth) {
            googleNativeLogin(
                serverClientId = "clientID",
                isSupported = true,
                filterByAuthorizedAccounts = false
            ),
            appleNativeLogin()
        }
    }


// Auth Screen
setContent {
     val login = supabaseClient.authUI.rememberLoginWithGoogle({ result ->
             when (result) {
                       is NativeSignInResult.Success -> {/* user successfully logged in */ }
                       is NativeSignInResult.ClosedByUser -> {/* user canceled the flow */ }
                       is NativeSignInResult.NetworkError -> {/* network error */ }
                       is NativeSignInResult.Error -> {/* internal or GoTrue error */ }
             }
      }) {
           //your fallback logic here
     }
    ...
    Button(                         
       onClick = { login.startFlow() }
    )
}

Additional context

⚠ ⚠NOTE: This is very experimental, only Android and Apple have native behavior other platforms rely on fallback as default behavior

Happily open for discussion and suggestion on how we can expand this idea

jan-tennert and others added 30 commits July 1, 2023 21:41
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Bumps [com.soywiz.korlibs.krypto:krypto](https://github.com/korlibs/korge-next) from 4.0.6 to 4.0.7.
- [Release notes](https://github.com/korlibs/korge-next/releases)
- [Commits](https://github.com/korlibs/korge-next/commits)

---
updated-dependencies:
- dependency-name: com.soywiz.korlibs.krypto:krypto
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.vanniktech.maven.publish](https://github.com/vanniktech/gradle-maven-publish-plugin) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/vanniktech/gradle-maven-publish-plugin/releases)
- [Changelog](https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md)
- [Commits](vanniktech/gradle-maven-publish-plugin@0.25.2...0.25.3)

---
updated-dependencies:
- dependency-name: com.vanniktech.maven.publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…endabot/gradle/com.vanniktech.maven.publish-0.25.3

Bump com.vanniktech.maven.publish from 0.25.2 to 0.25.3
…endabot/gradle/com.soywiz.korlibs.krypto-krypto-4.0.7

Bump com.soywiz.korlibs.krypto:krypto from 4.0.6 to 4.0.7
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
…s-watchos

Add support for tvOS & watchOS
* Update kotlin to 1.9.0-RC

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

* Fix tests

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

* Add yarn.lock to caches

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

* Update yarn.lock

* Remove change regarding caching

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

* Update kotlin

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

---------

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
* Add logout scope parameter

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

* Delete code verifier on logout

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

* Fix tests

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>

---------

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
…ommunity#224)

Bumps [com.soywiz.korlibs.krypto:krypto](https://github.com/korlibs/korge-next) from 4.0.6 to 4.0.8.
- [Release notes](https://github.com/korlibs/korge-next/releases)
- [Commits](https://github.com/korlibs/korge-next/commits)

---
updated-dependencies:
- dependency-name: com.soywiz.korlibs.krypto:krypto
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jan Tennert <jan.m.tennert@gmail.com>
…munity#225)

Bumps [com.vanniktech.maven.publish](https://github.com/vanniktech/gradle-maven-publish-plugin) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/vanniktech/gradle-maven-publish-plugin/releases)
- [Changelog](https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md)
- [Commits](vanniktech/gradle-maven-publish-plugin@0.25.2...0.25.3)

---
updated-dependencies:
- dependency-name: com.vanniktech.maven.publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Conflicts:
#	gradle.properties
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
The README file has been updated to include recent additions to the platform support. NodeJS has been included in the JS module, and tvOS and watchOS have been added to the list of modules. This provides a clear and updated overview of platform compatibility for users.

Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
Signed-off-by: TheRealJan <jan.m.tennert@gmail.com>
@temk0 temk0 marked this pull request as ready for review August 4, 2023 08:07
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
gradle.properties Outdated Show resolved Hide resolved
plugins/ComposeAuth/README.md Outdated Show resolved Hide resolved
@temk0 temk0 requested a review from jan-tennert August 7, 2023 09:22
Copy link
Collaborator

@jan-tennert jan-tennert left a comment

Choose a reason for hiding this comment

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

Just small things

README.md Outdated
@@ -23,6 +23,9 @@ Supported targets:

❌ = not supported

🟡 = supported, relays on (fallback)OAuth as main flow
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
🟡 = supported, relays on (fallback)OAuth as main flow
🟡 = supported, relies on (fallback) OAuth as main flow

# Support

Currently, Compose Auth only supports native login for
Android with Google and iOS with Apple, other variations such as JS relay on fallback which
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Android with Google and iOS with Apple, other variations such as JS relay on fallback which
Android with Google and iOS with Apple, other variations such as JS rely on fallback which


Currently, Compose Auth only supports native login for
Android with Google and iOS with Apple, other variations such as JS relay on fallback which
by default is GoTrue-kt OAuth flow.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
by default is GoTrue-kt OAuth flow.
by default is gotrue-kt OAuth flow.

Either GoTrue or gotrue-kt

Comment on lines 37 to 48
val action = client.composeAuth.rememberLoginWithGoogle(
onResult = { result ->
when (result) {
is NativeSignInResult.Success -> {}
is NativeSignInResult.ClosedByUser -> {}
is NativeSignInResult.Error -> {}
is NativeSignInResult.NetworkError -> {}
}
},
fallback = {
// optional: only add fallback if you like to use custom fallback
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
val action = client.composeAuth.rememberLoginWithGoogle(
onResult = { result ->
when (result) {
is NativeSignInResult.Success -> {}
is NativeSignInResult.ClosedByUser -> {}
is NativeSignInResult.Error -> {}
is NativeSignInResult.NetworkError -> {}
}
},
fallback = {
// optional: only add fallback if you like to use custom fallback
}
val action = client.composeAuth.rememberLoginWithGoogle(
onResult = { result ->
when (result) {
is NativeSignInResult.Success -> {}
is NativeSignInResult.ClosedByUser -> {}
is NativeSignInResult.Error -> {}
is NativeSignInResult.NetworkError -> {}
}
},
fallback = {
// optional: only add fallback if you like to use custom fallback
}

Copy link
Collaborator

@jan-tennert jan-tennert left a comment

Choose a reason for hiding this comment

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

going to fix the commits later, then merge it. Will be included in the next alpha version. Could also squash it, prob easier

@temk0
Copy link
Contributor Author

temk0 commented Aug 8, 2023

going to fix the commits later, then merge it. Will be included in the next alpha version. Could also squash it, prob easier

Great, looking forward for more PRs. Big thanks again for you feedback, really enjoyed improving the initial idea.

@jan-tennert jan-tennert merged commit 0a270d6 into supabase-community:development Aug 8, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants