I need to implement an ASP.NET Web API that supports querying users as SCIM filtering specs https://www.rfc-editor.org/rfc/rfc7644#section-3.4.2.2.
What is the fastest way to do that? I know that I need to implement a parser that can parse filtering expression, then execute that expression with the dedicated user repository and return selected entities, but that is a huge work to implement that parser from the scratch, right?
Is there any faster way or more standard way to support SCIM filtering?
Please see https://github.com/PowerDMS/Owin.Scim
I have implemented it such that Owin.Scim takes the filter string, whether a query filter or patch filter, normalizes it, and then constructs an expression tree / lambda predicate which you can use in linq.
What's not yet implemented is how to support SCIM's query-on-root - where you're filtering on multiple resource types at once.
ScimFilter
normalizes the string with support for resource extensions.
Patching is a whole separate process which uses a custom json.net contract resolver. At the time of this writing, ScimFilter will give you a list of PathFilterExpressions. (if you're querying, you'll only have one).
You can use an extension method to take a PathFilterExpression
and get back a strongly-typed predicate (Func<Resource, bool>
). See: https://github.com/PowerDMS/Owin.Scim/blob/master/source/Owin.Scim/Extensions/PathFilterExpressionExtensions.cs
Alternatively, you can grab the alpha Owin.Scim.Antlr dll. https://github.com/PowerDMS/Owin.Scim/tree/master/source/lib
This will give you the ScimFilterLexer
& ScimFilterParser
.