Skip to content

Commit cfae424

Browse files
jerryshi5945Arpan Kaphle
authored and
Arpan Kaphle
committed
Update the publick key credential get flow to use GIS json api.
Test: Unit test, and test on device Bug: 270182330 Change-Id: I25100adf372e101390b9a719aed97da8dc2d3cb2
1 parent eda123f commit cfae424

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

credentials/credentials-play-services-auth/build.gradle

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ dependencies {
3131
}
3232

3333
// Closed source dependencies
34-
implementation(libs.playServicesAuth) {
34+
implementation(libs.playServicesAuth){
3535
exclude group: "androidx.loader"
3636
exclude group: "androidx.fragment"
37+
exclude group: "androidx.core"
38+
}
39+
40+
implementation(libs.playServicesFido){
41+
exclude group: "androidx.loader"
42+
exclude group: "androidx.fragment"
43+
exclude group: "androidx.core"
3744
}
38-
implementation(libs.playServicesFido)
3945

4046
androidTestImplementation(libs.junit)
4147
androidTestImplementation(libs.testExtJunit)
@@ -47,6 +53,9 @@ dependencies {
4753
androidTestImplementation(libs.multidex)
4854
androidTestImplementation(project(":internal-testutils-truth"))
4955
androidTestImplementation(libs.kotlinCoroutinesAndroid)
56+
androidTestImplementation("androidx.core:core-ktx:1.10.0")
57+
androidTestImplementation("androidx.fragment:fragment:1.5.7")
58+
androidTestImplementation("androidx.fragment:fragment-ktx:1.5.7")
5059
}
5160

5261
android {

credentials/credentials-play-services-auth/src/main/java/androidx/credentials/playservices/controllers/BeginSignIn/BeginSignInControllerUtility.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ package androidx.credentials.playservices.controllers.BeginSignIn
3535
import androidx.credentials.GetCredentialRequest
3636
import androidx.credentials.GetPasswordOption
3737
import androidx.credentials.GetPublicKeyCredentialOption
38-
import androidx.credentials.playservices.controllers.CreatePublicKeyCredential.PublicKeyCredentialControllerUtility.Companion.convertToPlayAuthPasskeyRequest
38+
import androidx.credentials.playservices.controllers.CreatePublicKeyCredential.PublicKeyCredentialControllerUtility.Companion.convertToPlayAuthPasskeyJsonRequest
3939
import com.google.android.gms.auth.api.identity.BeginSignInRequest
4040
import com.google.android.gms.auth.api.identity.BeginSignInRequest.GoogleIdTokenRequestOptions
4141
import com.google.android.libraries.identity.googleid.GetGoogleIdOption
@@ -64,8 +64,8 @@ class BeginSignInControllerUtility {
6464
)
6565
autoSelect = autoSelect || option.isAutoSelectAllowed
6666
} else if (option is GetPublicKeyCredentialOption && !isPublicKeyCredReqFound) {
67-
requestBuilder.setPasskeysSignInRequestOptions(
68-
convertToPlayAuthPasskeyRequest(option)
67+
requestBuilder.setPasskeyJsonSignInRequestOptions(
68+
convertToPlayAuthPasskeyJsonRequest(option)
6969
)
7070
isPublicKeyCredReqFound = true
7171
// TODO(b/262924507) : watch for GIS update on single vs multiple options of a

credentials/credentials-play-services-auth/src/main/java/androidx/credentials/playservices/controllers/CreatePublicKeyCredential/PublicKeyCredentialControllerUtility.kt

+7-20
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class PublicKeyCredentialControllerUtility {
162162
if (clientExtensionResults != null) {
163163
try {
164164
val uvmEntries = clientExtensionResults.uvmEntries
165-
val uvmEntriesList = uvmEntries.uvmEntryList
165+
val uvmEntriesList = uvmEntries?.uvmEntryList
166166
if (uvmEntriesList != null) {
167167
val uvmEntriesJSON = JSONArray()
168168
for (entry in uvmEntriesList) {
@@ -222,27 +222,14 @@ class PublicKeyCredentialControllerUtility {
222222

223223
/**
224224
* Converts from the Credential Manager public key credential option to the Play Auth
225-
* Module passkey option.
225+
* Module passkey json option.
226226
*
227-
* @throws JSONException If rpId or challenge either do not
228-
* exist or are empty in the initial request json
229227
*/
230-
fun convertToPlayAuthPasskeyRequest(request: GetPublicKeyCredentialOption):
231-
BeginSignInRequest.PasskeysRequestOptions {
232-
// TODO(b/262924507) : Make sure this is in compliance with w3 as impl continues
233-
// TODO(b/262924507) : Improve codebase readability as done here
234-
// (readable error capture + docs/etc)
235-
val json = JSONObject(request.requestJson)
236-
val rpId = json.optString("rpId", "")
237-
if (rpId.isEmpty()) {
238-
throw JSONException("GetPublicKeyCredentialOption - rpId not specified in the " +
239-
"request or is unexpectedly empty")
240-
}
241-
val challenge = getChallenge(json)
242-
return BeginSignInRequest.PasskeysRequestOptions.Builder()
228+
fun convertToPlayAuthPasskeyJsonRequest(option: GetPublicKeyCredentialOption):
229+
BeginSignInRequest.PasskeyJsonRequestOptions {
230+
return BeginSignInRequest.PasskeyJsonRequestOptions.Builder()
243231
.setSupported(true)
244-
.setRpId(rpId)
245-
.setChallenge(challenge)
232+
.setRequestJson(option.requestJson)
246233
.build()
247234
}
248235

@@ -536,4 +523,4 @@ class PublicKeyCredentialControllerUtility {
536523
ErrorCode.TIMEOUT_ERR to TimeoutError()
537524
)
538525
}
539-
}
526+
}

gradle/libs.versions.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ okhttpMockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version =
223223
okio = { module = "com.squareup.okio:okio", version = "3.1.0" }
224224
playFeatureDelivery = { module = "com.google.android.play:feature-delivery", version = "2.0.1" }
225225
playCore = { module = "com.google.android.play:core", version = "1.10.3" }
226-
playServicesAuth = {module = "com.google.android.gms:play-services-auth", version = "20.4.0"}
226+
playServicesAuth = {module = "com.google.android.gms:play-services-auth", version = "20.5.0"}
227227
playServicesBase = { module = "com.google.android.gms:play-services-base", version = "17.0.0" }
228228
playServicesBasement = { module = "com.google.android.gms:play-services-basement", version = "17.0.0" }
229229
playServicesDevicePerformance = { module = "com.google.android.gms:play-services-deviceperformance", version = "16.0.0" }
230-
playServicesFido = {module = "com.google.android.gms:play-services-fido", version = "19.0.0"}
230+
playServicesFido = {module = "com.google.android.gms:play-services-fido", version = "20.0.1"}
231231
playServicesWearable = { module = "com.google.android.gms:play-services-wearable", version = "17.1.0" }
232232
paparazzi = { module = "app.cash.paparazzi:paparazzi", version.ref = "paparazzi" }
233233
paparazziNativeJvm = { module = "app.cash.paparazzi:layoutlib-native-jdk11", version.ref = "paparazziNative" }

0 commit comments

Comments
 (0)