-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add getReadableIds and use in filterReadAccess #277 #278
base: master
Are you sure you want to change the base?
Conversation
Following discussion with @kevinphippsstfc, have:
This shouldn't change the performance of existing usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks great, thanks! I've just requested a few additions to the comments to hopefully help future developers.
I'm wondering how best to test this given that I don't think the part of the code using "restrictions" will get tested much (if at all?) by the unit and integration tests. We could do with testing it on an ICAT containing some of the usual InvestigationUser and InstrumentScientist rules/restrictions.
…/icatproject/icat.server into 277_filterReadAccess_improvement
Have added/expanded the documentation of the new/modified functions, if anything still needs clarifying just let me know. |
Have expanded
Note that the last two are only affected if an Some implicit testing was taking place, as if the authorization were overly restrictive (i.e. if
along with some tests in TestWS (as the functionality in question is in Gatekeeper, I only changed TestRS as part of this PR). I have expanded these tests to also assert that the tests are not too permissive, by performing searches as the The existing Also refactored code to set up |
Co-authored-by: Viktor Bozhinov <[email protected]>
Changes
Added
getReadableIds
function. The logic here is the same as ingetReadable
, however we accept and return lists of IDs rather than entities. When dealing with the free text search results, we only have IDs. Before we were finding the bean for each ID in turn in order to run authorisation on it, then proceeding to return the ID. But as we already have theklass
of the entitity and the ID from Lucene we can simply operate on these instead.Instead of hardcoding the number of results to get from Lucene at 1000, instead use the
maxIdsInQuery
setting. This is the limit we would send in one batch to the DB ingetReadable
/getReadableIds
anyway, and the default value of 500 and max for Oracle of 1000 is the same order of magnitude as what we were currently using.Impact
I ran a number of searches against my local development components, using the lils.yml as my dummy data. This contains:
I searched for
*
(returning all entities before authorising) as bothroot
and the non-rooticatuser
, representing best and worst case scenarios (all data visible, no data visible and needing to check DB for rules) for the old and new setup withmaxIdsInQuery
set to 500 and 1000. All times are in ms, and is measured between the firstEntityBeanManager - Got X results from Lucene
andEntityBeanManager - Returning Y results
logs made by icat.server.root
Old method is comparable for DS and DF since we only loop until we reach 300 accepted results, then return.
New only submits one batch of entities to check, and returns in consistently ~12ms.
non-root
Old method takes around 1 to 2 ms per entity checked as we need to check every ID individually before being sure none are authorised.
New method takes roughly the same amount of time for Investigations and DS as these both require a single batch of IDs (less than the limit in settings. Datafiles takes around half the time when the limit is doubled to 1000, as we only need to send half as many batches (averaging 24ms per batch).
Also searched for a specific single result using
id:...
in both old and new setup as root:Times are comparable with old and new approaches. For the new method, the time taken to authorise 1 result and hundreds (as in the
*
example) was also comparable.It's worth noting that in these tests I didn't actually have any rules in the DB to evaluate.