-
Notifications
You must be signed in to change notification settings - Fork 50
feat(android): Upgrade native SDK to 3.9.0 and adapt to breaking changes #671
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ buildscript { | |
| } | ||
|
|
||
| dependencies { | ||
| classpath "com.android.tools.build:gradle:8.4.0" | ||
| classpath "com.android.tools.build:gradle:8.3.0" | ||
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
| } | ||
| } | ||
|
|
@@ -31,18 +31,18 @@ rootProject.allprojects { | |
| } | ||
|
|
||
| android { | ||
| compileSdk 34 | ||
| compileSdk 35 | ||
|
|
||
| if (project.android.hasProperty("namespace")) { | ||
| namespace libApplicationId | ||
| } | ||
| compileOptions { | ||
| sourceCompatibility JavaVersion.VERSION_1_8 | ||
| targetCompatibility JavaVersion.VERSION_1_8 | ||
| sourceCompatibility JavaVersion.VERSION_11 | ||
| targetCompatibility JavaVersion.VERSION_11 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets updated the java version to 17 . |
||
| } | ||
|
|
||
| kotlinOptions { | ||
| jvmTarget = '1.8' | ||
| jvmTarget = '11' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets update to 17 |
||
| } | ||
|
|
||
| sourceSets { | ||
|
|
@@ -51,9 +51,10 @@ android { | |
| } | ||
|
|
||
| defaultConfig { | ||
| minSdkVersion 21 | ||
| minSdkVersion 24 | ||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| manifestPlaceholders = [auth0Domain: "test-domain", auth0Scheme: "test"] | ||
| manifestPlaceholders = [auth0Domain: "dev-z0xy0f8x5xj51m2q.us.auth0.com", auth0Scheme: "https"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't hardcode your domain id here. Use a place holder in commited changes |
||
| consumerProguardFiles '../proguard/proguard-gson.pro', '../proguard/proguard-okio.pro', '../proguard/proguard-jetpack.pro' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these from the Auth0.Android SDK ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The proguard-jetpack.pro file is a new requirement for v3.x of the native SDK because it now uses the AndroidX Biometric and Credentials libraries, and this file prevents their classes from being stripped. |
||
| } | ||
|
|
||
| buildTypes { | ||
|
|
@@ -71,15 +72,20 @@ android { | |
| } | ||
|
|
||
| dependencies { | ||
| implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
| //noinspection GradleDynamicVersion | ||
| implementation 'com.auth0.android:auth0:2.11.0' | ||
| implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" | ||
| implementation 'com.auth0.android:auth0:3.9.0' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the latest version of 3.10.0 |
||
| implementation "androidx.biometric:biometric:1.1.0" | ||
| implementation 'com.squareup.okhttp3:okhttp:4.12.0' | ||
| implementation 'androidx.browser:browser:1.4.0' | ||
| implementation 'androidx.core:core-ktx:1.6.0' | ||
| implementation 'androidx.appcompat:appcompat:1.6.0' | ||
| implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need all these dependencies ? I don't think so
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need them because |
||
|
|
||
| testImplementation 'junit:junit:4.13.2' | ||
| testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0' | ||
| testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0" | ||
| testImplementation 'com.jayway.awaitility:awaitility:1.7.0' | ||
| testImplementation 'org.robolectric:robolectric:4.6.1' | ||
| testImplementation 'org.robolectric:robolectric:4.8.1' | ||
| testImplementation 'androidx.test.espresso:espresso-intents:3.5.1' | ||
| testImplementation 'com.auth0:java-jwt:3.19.1' | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,68 +2,70 @@ package com.auth0.auth0_flutter | |
|
|
||
| import android.app.Activity | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import androidx.annotation.NonNull | ||
| import com.auth0.android.authentication.AuthenticationAPIClient | ||
| import androidx.fragment.app.FragmentActivity | ||
| import com.auth0.android.authentication.storage.AuthenticationLevel | ||
| import com.auth0.android.authentication.storage.LocalAuthenticationOptions | ||
| import com.auth0.android.authentication.storage.SecureCredentialsManager | ||
| import com.auth0.android.authentication.storage.SharedPreferencesStorage | ||
| import com.auth0.auth0_flutter.request_handlers.MethodCallRequest | ||
| import com.auth0.auth0_flutter.request_handlers.credentials_manager.CredentialsManagerRequestHandler | ||
| import com.auth0.auth0_flutter.utils.RequestCodes | ||
| import io.flutter.plugin.common.MethodCall | ||
| import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
| import io.flutter.plugin.common.MethodChannel.Result | ||
| import io.flutter.plugin.common.PluginRegistry | ||
|
|
||
| class CredentialsManagerMethodCallHandler(private val requestHandlers: List<CredentialsManagerRequestHandler>) : | ||
| MethodCallHandler, PluginRegistry.ActivityResultListener { | ||
| class CredentialsManagerMethodCallHandler(private val requestHandlers: List<CredentialsManagerRequestHandler>) : MethodCallHandler { | ||
| lateinit var activity: Activity | ||
| lateinit var context: Context | ||
|
|
||
| var credentialsManager: SecureCredentialsManager? = null | ||
|
|
||
| override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { | ||
| override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { | ||
| val requestHandler = requestHandlers.find { it.method == call.method } | ||
|
|
||
| if (requestHandler != null) { | ||
| val request = MethodCallRequest.fromCall(call) | ||
| val activity = this.activity | ||
|
|
||
| val configuration = | ||
| request.data["credentialsManagerConfiguration"] as Map<*, *>? | ||
| val configuration = request.data["credentialsManagerConfiguration"] as Map<*, *>? | ||
|
|
||
| val sharedPreferenceConfiguration = configuration?.get("android") | ||
| val sharedPreferenceName: String? = if (sharedPreferenceConfiguration != null) { | ||
| (sharedPreferenceConfiguration as Map<String, String>).get("sharedPreferencesName") | ||
| (sharedPreferenceConfiguration as Map<String, String>)["sharedPreferencesName"] | ||
| } else null | ||
|
|
||
| val api = AuthenticationAPIClient(request.account) | ||
| val storage = sharedPreferenceName?.let { | ||
| SharedPreferencesStorage(context, it) | ||
| } ?: SharedPreferencesStorage(context) | ||
| credentialsManager = | ||
| credentialsManager ?: SecureCredentialsManager(context, api, storage) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't remove this code. This is to ensure we don't create a new instance of CredentialsManager each time this method is called . Your current implementation creates a new instance of SecureCredentialsManager each time. Add this check in your current workflow |
||
|
|
||
| val credentialsManager = credentialsManager as SecureCredentialsManager | ||
| val localAuthentication = | ||
| request.data.get("localAuthentication") as Map<String, String>? | ||
| val localAuthentication = request.data["localAuthentication"] as Map<String, String>? | ||
| val credentialsManager: SecureCredentialsManager | ||
|
|
||
| if (localAuthentication != null) { | ||
| val title = localAuthentication["title"] | ||
| val description = localAuthentication["description"] | ||
| credentialsManager.requireAuthentication( | ||
| activity, | ||
| RequestCodes.AUTH_REQ_CODE, | ||
| title, | ||
| description | ||
| ) | ||
| if (activity !is FragmentActivity) { | ||
| result.error( | ||
| "credentialsManager#biometric-error", | ||
| "The Activity is not a FragmentActivity, which is required for biometric authentication.", | ||
| null | ||
| ) | ||
| return | ||
| } | ||
|
|
||
| val builder = LocalAuthenticationOptions.Builder() | ||
| localAuthentication["title"]?.let { builder.setTitle(it) } | ||
| localAuthentication["description"]?.let { builder.setDescription(it) } | ||
| localAuthentication["cancelTitle"]?.let { builder.setNegativeButtonText(it) } | ||
|
|
||
| builder.setAuthenticationLevel(AuthenticationLevel.STRONG) | ||
| builder.setDeviceCredentialFallback(true) | ||
|
|
||
|
|
||
| credentialsManager = SecureCredentialsManager(context, request.account, storage, activity, builder.build()) | ||
| } else { | ||
| credentialsManager = SecureCredentialsManager(context, request.account, storage) | ||
| } | ||
|
|
||
| requestHandler.handle(credentialsManager, context, request, result) | ||
| } else { | ||
| result.notImplemented() | ||
| } | ||
| } | ||
|
|
||
| override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean { | ||
| return credentialsManager?.checkAuthenticationResult(requestCode, resultCode) ?: true | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is being downgraded ?