Skip to content

Commit b302a50

Browse files
authored
Revert "Added Passkey authentication support" (#767)
2 parents b4dbd62 + 0e06b8c commit b302a50

24 files changed

+44
-1386
lines changed

EXAMPLES.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,5 +1242,4 @@ You might encounter errors similar to `PKIX path building failed: sun.security.p
12421242
The rules should be applied automatically if your application is using `minifyEnabled = true`. If you want to include them manually check the [proguard directory](proguard).
12431243
By default you should at least use the following files:
12441244
* `proguard-okio.pro`
1245-
* `proguard-gson.pro`
1246-
* `proguard-jetpack.pro`
1245+
* `proguard-gson.pro`

auth0/build.gradle

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ version = getVersionFromFile()
3434
logger.lifecycle("Using version ${version} for ${name}")
3535

3636
android {
37-
compileSdkVersion 34
37+
compileSdkVersion 31
3838

3939
defaultConfig {
4040
minSdkVersion 21
41-
targetSdkVersion 34
41+
targetSdkVersion 31
4242
versionCode 1
4343
versionName project.version
4444

4545
buildConfigField "String", "LIBRARY_NAME", "\"$project.rootProject.name\""
4646
buildConfigField "String", "VERSION_NAME", "\"${project.version}\""
4747

48-
consumerProguardFiles '../proguard/proguard-gson.pro', '../proguard/proguard-okio.pro', '../proguard/proguard-jetpack.pro'
48+
consumerProguardFiles '../proguard/proguard-gson.pro', '../proguard/proguard-okio.pro'
4949
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
5050
}
5151
lintOptions {
@@ -77,14 +77,13 @@ ext {
7777
powermockVersion = '2.0.9'
7878
coroutinesVersion = '1.6.2'
7979
biometricLibraryVersion = '1.1.0'
80-
credentialManagerVersion = "1.3.0"
8180
}
8281

8382

8483
dependencies {
8584
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
8685
implementation 'androidx.core:core-ktx:1.6.0'
87-
implementation 'androidx.appcompat:appcompat:1.6.0'
86+
implementation 'androidx.appcompat:appcompat:1.3.0'
8887
implementation 'androidx.browser:browser:1.4.0'
8988
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
9089
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
@@ -111,9 +110,6 @@ dependencies {
111110
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
112111

113112
testImplementation "androidx.biometric:biometric:$biometricLibraryVersion"
114-
115-
implementation "androidx.credentials:credentials-play-services-auth:$credentialManagerVersion"
116-
implementation "androidx.credentials:credentials:$credentialManagerVersion"
117113
}
118114

119115
apply from: rootProject.file('gradle/jacoco.gradle')

auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.kt

Lines changed: 21 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import com.auth0.android.request.internal.ResponseUtils.isNetworkError
1212
import com.auth0.android.result.Challenge
1313
import com.auth0.android.result.Credentials
1414
import com.auth0.android.result.DatabaseUser
15-
import com.auth0.android.result.PasskeyChallengeResponse
16-
import com.auth0.android.result.PasskeyRegistrationResponse
1715
import com.auth0.android.result.UserProfile
1816
import com.google.gson.Gson
1917
import okhttp3.HttpUrl.Companion.toHttpUrl
@@ -153,102 +151,6 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
153151
return loginWithToken(parameters)
154152
}
155153

156-
157-
/**
158-
* Log in a user using passkeys.
159-
* This should be called after the client has received the Passkey challenge and Auth-session from the server .
160-
* Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
161-
* to learn how to enable it.
162-
*
163-
* @param authSession the auth session received from the server as part of the public challenge request.
164-
* @param authResponse the public key credential response to be sent to the server
165-
* @param parameters additional parameters to be sent as part of the request
166-
* @return a request to configure and start that will yield [Credentials]
167-
*/
168-
internal fun signinWithPasskey(
169-
authSession: String,
170-
authResponse: PublicKeyCredentialResponse,
171-
parameters: Map<String, String>
172-
): AuthenticationRequest {
173-
val params = ParameterBuilder.newBuilder().apply {
174-
setGrantType(ParameterBuilder.GRANT_TYPE_PASSKEY)
175-
set(AUTH_SESSION_KEY, authSession)
176-
addAll(parameters)
177-
}.asDictionary()
178-
179-
return loginWithToken(params)
180-
.addParameter(
181-
AUTH_RESPONSE_KEY,
182-
Gson().toJsonTree(authResponse)
183-
) as AuthenticationRequest
184-
}
185-
186-
187-
/**
188-
* Register a user and returns a challenge.
189-
* Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
190-
* to learn how to enable it.
191-
*
192-
* @param userMetadata user information of the client
193-
* @param parameters additional parameter to be sent as part of the request
194-
* @return a request to configure and start that will yield [PasskeyRegistrationResponse]
195-
*/
196-
internal fun signupWithPasskey(
197-
userMetadata: UserMetadataRequest,
198-
parameters: Map<String, String>,
199-
): Request<PasskeyRegistrationResponse, AuthenticationException> {
200-
val user = Gson().toJsonTree(userMetadata)
201-
val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
202-
.addPathSegment(PASSKEY_PATH)
203-
.addPathSegment(REGISTER_PATH)
204-
.build()
205-
206-
val params = ParameterBuilder.newBuilder().apply {
207-
setClientId(clientId)
208-
parameters[ParameterBuilder.REALM_KEY]?.let {
209-
setRealm(it)
210-
}
211-
}.asDictionary()
212-
213-
val passkeyRegistrationAdapter: JsonAdapter<PasskeyRegistrationResponse> = GsonAdapter(
214-
PasskeyRegistrationResponse::class.java, gson
215-
)
216-
val post = factory.post(url.toString(), passkeyRegistrationAdapter)
217-
.addParameters(params) as BaseRequest<PasskeyRegistrationResponse, AuthenticationException>
218-
post.addParameter(USER_PROFILE_KEY, user)
219-
return post
220-
}
221-
222-
223-
/**
224-
* Request for a challenge to initiate a passkey login flow
225-
* Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
226-
* to learn how to enable it.
227-
*
228-
* @param realm An optional connection name
229-
* @return a request to configure and start that will yield [PasskeyChallengeResponse]
230-
*/
231-
internal fun passkeyChallenge(
232-
realm: String?
233-
): Request<PasskeyChallengeResponse, AuthenticationException> {
234-
val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
235-
.addPathSegment(PASSKEY_PATH)
236-
.addPathSegment(CHALLENGE_PATH)
237-
.build()
238-
239-
val parameters = ParameterBuilder.newBuilder().apply {
240-
setClientId(clientId)
241-
realm?.let { setRealm(it) }
242-
}.asDictionary()
243-
244-
val passkeyChallengeAdapter: JsonAdapter<PasskeyChallengeResponse> = GsonAdapter(
245-
PasskeyChallengeResponse::class.java, gson
246-
)
247-
248-
return factory.post(url.toString(), passkeyChallengeAdapter)
249-
.addParameters(parameters)
250-
}
251-
252154
/**
253155
* Log in a user using an Out Of Band authentication code after they have received the 'mfa_required' error.
254156
* The MFA token tells the server the username or email, password, and realm values sent on the first request.
@@ -793,7 +695,8 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
793695
val parameters = ParameterBuilder.newBuilder()
794696
.setClientId(clientId)
795697
.setGrantType(ParameterBuilder.GRANT_TYPE_AUTHORIZATION_CODE)
796-
.set(OAUTH_CODE_KEY, authorizationCode).set(REDIRECT_URI_KEY, redirectUri)
698+
.set(OAUTH_CODE_KEY, authorizationCode)
699+
.set(REDIRECT_URI_KEY, redirectUri)
797700
.set("code_verifier", codeVerifier)
798701
.asDictionary()
799702
val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
@@ -833,26 +736,26 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
833736
.addPathSegment(OAUTH_PATH)
834737
.addPathSegment(TOKEN_PATH)
835738
.build()
836-
val requestParameters =
837-
ParameterBuilder.newBuilder()
838-
.setClientId(clientId)
839-
.addAll(parameters)
840-
.asDictionary()
739+
val requestParameters = ParameterBuilder.newBuilder()
740+
.setClientId(clientId)
741+
.addAll(parameters)
742+
.asDictionary()
841743
val credentialsAdapter: JsonAdapter<Credentials> = GsonAdapter(
842744
Credentials::class.java, gson
843745
)
844746
val request = BaseAuthenticationRequest(
845-
factory.post(url.toString(), credentialsAdapter), clientId, baseURL
747+
factory.post(url.toString(), credentialsAdapter),
748+
clientId,
749+
baseURL
846750
)
847751
request.addParameters(requestParameters)
848752
return request
849753
}
850754

851755
private fun profileRequest(): Request<UserProfile, AuthenticationException> {
852-
val url =
853-
auth0.getDomainUrl().toHttpUrl().newBuilder()
854-
.addPathSegment(USER_INFO_PATH)
855-
.build()
756+
val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
757+
.addPathSegment(USER_INFO_PATH)
758+
.build()
856759
val userProfileAdapter: JsonAdapter<UserProfile> = GsonAdapter(
857760
UserProfile::class.java, gson
858761
)
@@ -879,9 +782,6 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
879782
private const val SUBJECT_TOKEN_KEY = "subject_token"
880783
private const val SUBJECT_TOKEN_TYPE_KEY = "subject_token_type"
881784
private const val USER_METADATA_KEY = "user_metadata"
882-
private const val AUTH_SESSION_KEY = "auth_session"
883-
private const val AUTH_RESPONSE_KEY = "authn_response"
884-
private const val USER_PROFILE_KEY = "user_profile"
885785
private const val SIGN_UP_PATH = "signup"
886786
private const val DB_CONNECTIONS_PATH = "dbconnections"
887787
private const val CHANGE_PASSWORD_PATH = "change_password"
@@ -893,23 +793,24 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
893793
private const val REVOKE_PATH = "revoke"
894794
private const val MFA_PATH = "mfa"
895795
private const val CHALLENGE_PATH = "challenge"
896-
private const val PASSKEY_PATH = "passkey"
897-
private const val REGISTER_PATH = "register"
898796
private const val HEADER_AUTHORIZATION = "Authorization"
899797
private const val WELL_KNOWN_PATH = ".well-known"
900798
private const val JWKS_FILE_PATH = "jwks.json"
901799
private fun createErrorAdapter(): ErrorAdapter<AuthenticationException> {
902800
val mapAdapter = forMap(GsonProvider.gson)
903801
return object : ErrorAdapter<AuthenticationException> {
904802
override fun fromRawResponse(
905-
statusCode: Int, bodyText: String, headers: Map<String, List<String>>
803+
statusCode: Int,
804+
bodyText: String,
805+
headers: Map<String, List<String>>
906806
): AuthenticationException {
907807
return AuthenticationException(bodyText, statusCode)
908808
}
909809

910810
@Throws(IOException::class)
911811
override fun fromJsonResponse(
912-
statusCode: Int, reader: Reader
812+
statusCode: Int,
813+
reader: Reader
913814
): AuthenticationException {
914815
val values = mapAdapter.fromJson(reader)
915816
return AuthenticationException(values, statusCode)
@@ -918,11 +819,13 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
918819
override fun fromException(cause: Throwable): AuthenticationException {
919820
if (isNetworkError(cause)) {
920821
return AuthenticationException(
921-
"Failed to execute the network request", NetworkErrorException(cause)
822+
"Failed to execute the network request",
823+
NetworkErrorException(cause)
922824
)
923825
}
924826
return AuthenticationException(
925-
"Something went wrong", Auth0Exception("Something went wrong", cause)
827+
"Something went wrong",
828+
Auth0Exception("Something went wrong", cause)
926829
)
927830
}
928831
}

auth0/src/main/java/com/auth0/android/authentication/ParameterBuilder.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ public class ParameterBuilder private constructor(parameters: Map<String, String
159159
"http://auth0.com/oauth/grant-type/passwordless/otp"
160160
public const val GRANT_TYPE_TOKEN_EXCHANGE: String =
161161
"urn:ietf:params:oauth:grant-type:token-exchange"
162-
public const val GRANT_TYPE_PASSKEY :String = "urn:okta:params:oauth:grant-type:webauthn"
163162
public const val SCOPE_OPENID: String = "openid"
164163
public const val SCOPE_OFFLINE_ACCESS: String = "openid offline_access"
165164
public const val SCOPE_KEY: String = "scope"

0 commit comments

Comments
 (0)