Skip to content

Commit 38a0111

Browse files
liutikasGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "Update the publick key credential get flow to use GIS json api." into androidx-main
2 parents ee686e4 + cfae424 commit 38a0111

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
@@ -165,7 +165,7 @@ class PublicKeyCredentialControllerUtility {
165165
if (clientExtensionResults != null) {
166166
try {
167167
val uvmEntries = clientExtensionResults.uvmEntries
168-
val uvmEntriesList = uvmEntries.uvmEntryList
168+
val uvmEntriesList = uvmEntries?.uvmEntryList
169169
if (uvmEntriesList != null) {
170170
val uvmEntriesJSON = JSONArray()
171171
for (entry in uvmEntriesList) {
@@ -239,27 +239,14 @@ class PublicKeyCredentialControllerUtility {
239239

240240
/**
241241
* Converts from the Credential Manager public key credential option to the Play Auth
242-
* Module passkey option.
242+
* Module passkey json option.
243243
*
244-
* @throws JSONException If rpId or challenge either do not
245-
* exist or are empty in the initial request json
246244
*/
247-
fun convertToPlayAuthPasskeyRequest(request: GetPublicKeyCredentialOption):
248-
BeginSignInRequest.PasskeysRequestOptions {
249-
// TODO(b/262924507) : Make sure this is in compliance with w3 as impl continues
250-
// TODO(b/262924507) : Improve codebase readability as done here
251-
// (readable error capture + docs/etc)
252-
val json = JSONObject(request.requestJson)
253-
val rpId = json.optString("rpId", "")
254-
if (rpId.isEmpty()) {
255-
throw JSONException("GetPublicKeyCredentialOption - rpId not specified in the " +
256-
"request or is unexpectedly empty")
257-
}
258-
val challenge = getChallenge(json)
259-
return BeginSignInRequest.PasskeysRequestOptions.Builder()
245+
fun convertToPlayAuthPasskeyJsonRequest(option: GetPublicKeyCredentialOption):
246+
BeginSignInRequest.PasskeyJsonRequestOptions {
247+
return BeginSignInRequest.PasskeyJsonRequestOptions.Builder()
260248
.setSupported(true)
261-
.setRpId(rpId)
262-
.setChallenge(challenge)
249+
.setRequestJson(option.requestJson)
263250
.build()
264251
}
265252

@@ -581,4 +568,4 @@ class PublicKeyCredentialControllerUtility {
581568
ErrorCode.TIMEOUT_ERR to TimeoutError()
582569
)
583570
}
584-
}
571+
}

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)