Skip to content

Commit 628b73c

Browse files
committed
Sorting the scope before saving them with audience
1 parent 3ffefd1 commit 628b73c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

auth0/src/main/java/com/auth0/android/authentication/storage/BaseCredentialsManager.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.auth0.android.authentication.storage
22

3+
import android.util.Log
34
import androidx.annotation.VisibleForTesting
45
import com.auth0.android.authentication.AuthenticationAPIClient
56
import com.auth0.android.callback.Callback
@@ -213,6 +214,9 @@ public abstract class BaseCredentialsManager internal constructor(
213214
*/
214215
protected fun getAPICredentialsKey(audience: String, scope: String?): String {
215216
// Use audience if scope is null else use a combination of audience and scope
216-
return if (scope == null) audience else "$audience::${scope.replace(" ","::")}"
217+
if (scope == null) return audience
218+
val sortedScope = scope.split(" ").sorted().joinToString("::")
219+
return "$audience::${sortedScope}"
220+
217221
}
218222
}

auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,9 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
717717

718718
/**
719719
* Removes the credentials for the given audience from the storage if present.
720+
* @param audience Audience for which the [APICredentials] are stored
721+
* @param scope Optional scope for which the [APICredentials] are stored. If the credentials were initially fetched/stored with scope,
722+
* it is recommended to pass scope also while clearing them.
720723
*/
721724
override fun clearApiCredentials(audience: String, scope: String?) {
722725
val key = getAPICredentialsKey(audience, scope)

auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
764764

765765
/**
766766
* Removes the credentials for the given audience from the storage if present.
767+
* @param audience Audience for which the [APICredentials] are stored
768+
* @param scope Optional scope for which the [APICredentials] are stored. If the credentials were initially fetched/stored with scope,
769+
* it is recommended to pass scope also while clearing them.
767770
*/
768771
override fun clearApiCredentials(audience: String, scope: String?) {
769772
val key = getAPICredentialsKey(audience, scope)

0 commit comments

Comments
 (0)