From ad781b2f6045922df6672461107516e66157df59 Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Tue, 18 Jul 2023 10:39:41 +0100 Subject: [PATCH] Use a case-sensitive compare for `org_name` (#783) --- Auth0/ClaimValidators.swift | 2 +- Auth0Tests/ClaimValidatorsSpec.swift | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Auth0/ClaimValidators.swift b/Auth0/ClaimValidators.swift index 65b5ebd2..12e39ecc 100644 --- a/Auth0/ClaimValidators.swift +++ b/Auth0/ClaimValidators.swift @@ -300,7 +300,7 @@ struct IDTokenOrgNameValidator: JWTValidator { func validate(_ jwt: JWT) -> Auth0Error? { guard let actualOrgName = jwt.claim(name: "org_name").string else { return ValidationError.missingOrgName } - guard actualOrgName.caseInsensitiveCompare(expectedOrgName) == .orderedSame else { + guard actualOrgName == expectedOrgName.lowercased() else { return ValidationError.mismatchedOrgName(actual: actualOrgName, expected: expectedOrgName) } return nil diff --git a/Auth0Tests/ClaimValidatorsSpec.swift b/Auth0Tests/ClaimValidatorsSpec.swift index 6d53f0ff..0a2bdb0f 100644 --- a/Auth0Tests/ClaimValidatorsSpec.swift +++ b/Auth0Tests/ClaimValidatorsSpec.swift @@ -494,9 +494,9 @@ class ClaimValidatorsSpec: IDTokenValidatorBaseSpec { } } - it("should perform a case insensitive compare") { - let orgName = "aBc1234" - let expectedOrgName = "AbC1234" + it("should lowercase the expected org_name") { + let orgName = "abc1234" + let expectedOrgName = "ABC1234" let jwt = generateJWT(orgName: orgName) orgNameValidator = IDTokenOrgNameValidator(orgName: expectedOrgName)