Skip to content

Commit d260c5d

Browse files
committed
Sorting the scopes before appending with audience for mrrt key
1 parent 6691153 commit d260c5d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Auth0/CredentialsManager.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ public struct CredentialsManager {
163163
/// ```
164164
///
165165
/// - Parameter audience: Identifier of the API the stored API credentials are for.
166-
/// - Parameter scope: Scope of the stored API credentials. If API credentials are fetched with scope, it is recommended to pass the scope to clear them.
166+
/// - Parameter scope: Optional scope for which the API Credentials are stored. If the credentials were initially fetched/stored with scope,
167+
/// it is recommended to pass scope also while clearing them.
167168
/// - Returns: If the API credentials were removed.
168169
public func clear(forAudience audience: String,scope:String? = nil) -> Bool {
169170
let key = getAPICredentialsStorageKey(audience: audience, scope: scope)
@@ -719,7 +720,11 @@ public struct CredentialsManager {
719720
private func getAPICredentialsStorageKey(audience: String, scope: String?) -> String {
720721
// Use audience if scope is null else use a combination of audience and scope
721722
if let scope = scope {
722-
return "\(audience)::\(scope.replacingOccurrences(of: " ", with: "::"))"
723+
let normalisedScopes = scope
724+
.split(separator: " ")
725+
.sorted()
726+
.joined(separator: "::")
727+
return "\(audience)::\(normalisedScopes)"
723728
} else {
724729
return audience
725730
}

0 commit comments

Comments
 (0)