We have some large datasets (approx 300k records per tenant) that users may have access to large subsets of, and that queries may match large subsets of. This seems challenging because it doesn't seem like a great match for the lookup API (due to the large set of authorized records) or bulk-check (due to the large set of matched records.) And just to make it spicier- we need to handle counts, sorting, and pagination, which seems like we would need to process the entire dataset.
We're considering some alternatives, like making the authorization more coarse-grained by using the lookup API to get part of the way there (to a handful of items) and then using that data in the query, but that means less expressive authz policy. Or, something more exotic, like building out a table of subjects and authorized resources that could be joined, but that seems like a mess.
Thoughts/insights/suggestions?