Skip to content

[SPO] Add configurable drive item permissions support - #1259

Merged
timgrein merged 37 commits into
mainfrom
tim/configurable-drive-item-permissions
Jul 18, 2023
Merged

timgrein merged 37 commits into
mainfrom
tim/configurable-drive-item-permissions

Conversation

@timgrein

@timgrein timgrein commented Jul 12, 2023 •

Copy link
Copy Markdown
Contributor

Closes https://github.com/elastic/enterprise-search-team/issues/5164

This PR adds a RFC fetch_drive_item_permissions, which specifies whether drive item specific permissions should be fetched or not. Fetching drive item permissions is now also done via scrolling and not via fetching everything at once.

Using the $batch API to batch 20 permission requests for drive items into 1 reducing the number of requests drastically.

Note: We add siteUser and siteGroup for drive item permissions, but we don't fetch them during an access control sync yet. This will be part of another PR and will also be made configurable + the dependency checks will be added on the RFC side.

A separate PR adding the fetch_drive_item_permissions RFC will follow for Kibana.

Checklists

Pre-Review Checklist

  • this PR has a meaningful title
  • this PR links to all relevant github issues that it fixes or partially addresses
  • if there is no GH issue, please create it. Each PR should have a link to an issue
  • this PR has a thorough description
  • Covered the changes with automated tests
  • Tested the changes locally
  • Added a label for each target release version (example: v7.13.2, v7.14.0, v8.0.0)
  • Considered corresponding documentation changes

@timgrein timgrein changed the title tim/configurable-drive-item-permissions [SPO] Add configurable drive item permission support Jul 12, 2023
@timgrein timgrein changed the title [SPO] Add configurable drive item permission support [SPO] Add configurable drive item permissions support Jul 12, 2023
seanstory
seanstory previously approved these changes Jul 12, 2023

@seanstory seanstory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Have you shared the results of this branch yet with Gustavo? May be good to get confirmation of output before declaring victory.

"type": "bool",
"value": False,
},
"fetch_drive_item_permissions": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need a corresponding kibana PR, and a corresponding docs PR. Also, CC @artem-shelkovnikov who is working on SPO ftest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added RFC to functional test connector.json with 0719134

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just merged the PR, you can update tests/sources/fixtures/sharepoint_online/connector.json to include the field now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added, but I've to decrement the order also here :)

Comment thread connectors/sources/sharepoint_online.py Outdated
"display": "toggle",
"label": "Fetch drive item permissions",
"order": 9,
"tooltip": "Enable this option to fetch drive item specific permissions. Note that this setting can potentially increase sync time.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leemthompo for review of copy (easier to do this now then have to come back and reword later)

@artem-shelkovnikov artem-shelkovnikov Jul 13, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the order needs to be decremented after #1255 (review) - it removes item no. 8

"identity": {
"email": prefixed_mail,
"username": prefixed_username,
"user_id": prefixed_user_id,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea. 👍

Comment thread connectors/sources/sharepoint_online.py Outdated
Comment thread connectors/sources/sharepoint_online.py Outdated
prefixed_mail = _prefix_email(email)
prefixed_username = _prefix_user(username)
prefixed_user_id = _prefix_user_id(user.get("id"))
id_ = email if email else username

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering can we use the user.get("id") here, instead of email/username?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we may want to have cross-system identities in the near future, it's probably better to use the email as the id as this is searchable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++. The sharepointID isn't typically easy for a customer to look up or reason about. But everyone knows their email address. This is why we decided to use email as the key (ES _id) for SPO.

"order": 9,
"tooltip": "Enable this option to fetch drive item specific permissions. Note that this setting can potentially increase sync time.",
"type": "bool",
"value": True,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected to be True by default, and I don't see 8.9 label in the PR, is migration needed if customers upgrade from 8.9 to 8.10?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would expect that we need one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, Chenhui. Tim, can you create and link an issue so we don't forget?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com>
Comment thread connectors/sources/sharepoint_online.py Outdated
@@ -606,9 +606,14 @@ async def drive_items(self, drive_id, url=None):
yield page

async def drive_item_permissions(self, drive_id, item_id):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's no way to fetch permissions in batch?

Do you think doing request batching could help here?

@timgrein timgrein Jul 13, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding: We would pile up to 20 drive items in memory and then fetch the permissions for these 20 at once?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Code will get ugly, but that's potentially 20x performance bump?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it, if it improves performance 🚀

timgrein and others added 2 commits July 13, 2023 15:39
Co-authored-by: Artem Shelkovnikov <lavatroublebubble@gmail.com>
seanstory
seanstory previously approved these changes Jul 17, 2023
Comment thread connectors/sources/sharepoint_online.py Outdated
Comment thread connectors/sources/sharepoint_online.py Outdated
async for site_drive in self.site_drives(site):
yield self._decorate_with_access_control(
site_drive, access_control
site_drive, site_access_control

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can drives not be given more granular access than their parent site?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're treated as lists AFAIU and they can have unique permissions. Will be addressed in a separate PR 👍 Issue for tracking: https://github.com/elastic/enterprise-search-team/issues/5363

Co-authored-by: Sean Story <sean.j.story@gmail.com>
@timgrein
timgrein requested a review from seanstory July 17, 2023 16:40
@timgrein
timgrein enabled auto-merge (squash) July 18, 2023 07:09
@timgrein
timgrein merged commit 4060efe into main Jul 18, 2023
@timgrein
timgrein deleted the tim/configurable-drive-item-permissions branch July 18, 2023 07:14
@github-actions

Copy link
Copy Markdown

💔 Failed to create backport PR(s)

The backport operation could not be completed due to the following error:
There are no branches to backport to. Aborting.

The backport PRs will be merged automatically after passing CI.

To backport manually run:
backport --pr 1259 --autoMerge --autoMergeMethod squash

@timgrein

Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
✅ pre-8.10-stable

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

timgrein added a commit that referenced this pull request Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants