Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison filters do not support case-insensitive matching #115

Open
BrandonGoddard-at opened this issue May 18, 2023 · 5 comments
Open
Assignees

Comments

@BrandonGoddard-at
Copy link

I believe there is an issue where comparison filters on string type attributes do not support case insensitive matching. I think this should be supported based on reading
https://datatracker.ietf.org/doc/html/rfc7643#section-7

caseExact  A Boolean value that specifies whether or not a string
         attribute is case sensitive.  The server SHALL use case
         sensitivity when evaluating filters.  For attributes that are
         case exact, the server SHALL preserve case for any value
         submitted.  If the attribute is case insensitive, the server
         MAY alter case for a submitted value.  Case sensitivity also
         impacts how attribute values MAY be compared against filter
         values (see [Section 3.4.2.2 of [RFC7644]](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2)).

and
https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2

When comparing attributes of type String, the case sensitivity for
   String type attributes SHALL be determined by the attribute's
   "caseExact" characteristic (see [Section 2.2 of [RFC7643]](https://datatracker.ietf.org/doc/html/rfc7643#section-2.2)).

i.e. a filter of displayName eq \"TestGroup\" should match testGroup and TestGROUP, etc.

I ran into this issue when trying to get an Azure AD app approved, and it looks like this is their interpretation of the spec as well

@thomaspoignant thomaspoignant self-assigned this May 21, 2023
@thomaspoignant
Copy link
Owner

Hey @BrandonGoddard-at thanks for reporting this issue, I've reread the RFC and, I think you're right this should be case insensitive.
Do you know if Azure AD is using the caseExact field?

Do you mind looking at the issue and opening a pull request for this?

@BrandonGoddard-at
Copy link
Author

Do you know if Azure AD is using the caseExact field?

Yes, at least for the standard cases in the core schema (i.e. group name filters). I've got a pretty blunt patch that we applied since all of our string fields we cared about were case insensitive. It looks something like this:

class CaseInsensitiveFilterTester extends Tester {
    override attrTest(path: Array<string>, r: any, op: (r: any) => boolean): boolean {
        if (path.length === 0) {
            return op(r?.toLocaleLowerCase() ?? r);
        }
        return super.attrTest(path, r, op);
    }
}

but If I have time I'll see if I can properly put up a PR that makes this an option on filter()

@thomaspoignant
Copy link
Owner

but If I have time I'll see if I can properly put up a PR that makes this an option on filter()

it would be awesome 🤓

@duaribiju
Copy link

Hello,
Any update on this issue, I can see case-insensitive is still not supported in the latest version.

@thomaspoignant
Copy link
Owner

@duaribiju I had no time to work on it, and it seems that @BrandonGoddard-at had no time neither.

If you want to give it a try you are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants