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

Moved users_picker profile custom picker to contacts #3487

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

andrey18106
Copy link

Moving the users_picker as it was planned with @DaphneMuller and @julien-nc.

But there is a conflict in NcSelect component ([Vue warn]: You may have an infinite update loop in a component render function.). It works with vue 2.7.14, but not with vue (2.6.14) in contacts, maybe @ChristophWurst can help with it and decide where do we want to move the profile picker.

@julien-nc
Copy link
Member

Weird thing: NcSelect works fine in other places in Contacts even with vue@2.6.14.

Also worth mentioning: The profile picker component works fine in https://github.com/nextcloud/users_picker and we can reproduce the problem there when downgrading vue to 2.6.14.

@ChristophWurst
Copy link
Member

Moving the users_picker as it was planned with @DaphneMuller and @julien-nc.

So what is the plan? Who will maintain that code once it's been moved into this repo?

lib/Reference/ProfilePickerReferenceProvider.php Outdated Show resolved Hide resolved
lib/Reference/ProfilePickerReferenceProvider.php Outdated Show resolved Hide resolved
lib/Reference/ProfilePickerReferenceProvider.php Outdated Show resolved Hide resolved
src/components/ProfilePicker/ProfilesCustomPicker.vue Outdated Show resolved Hide resolved
src/components/ProfilePicker/ProfilesCustomPicker.vue Outdated Show resolved Hide resolved
src/components/ProfilePicker/ProfilesCustomPicker.vue Outdated Show resolved Hide resolved
src/components/ProfilePicker/ProfilesCustomPicker.vue Outdated Show resolved Hide resolved
src/components/ProfilePicker/ProfilesCustomPicker.vue Outdated Show resolved Hide resolved
src/components/ProfilePicker/icons/UserIcon.vue Outdated Show resolved Hide resolved
@ChristophWurst ChristophWurst added the 2. developing Work in progress label Jun 27, 2023
andrey18106 and others added 2 commits June 30, 2023 14:14
Co-authored-by: Christoph Wurst <ChristophWurst@users.noreply.github.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Patch coverage has no change and project coverage change: -1.82% ⚠️

Comparison is base (33060a4) 1.81% compared to head (5ca4d6c) 0.00%.
Report is 167 commits behind head on main.

❗ Current head 5ca4d6c differs from pull request most recent head 74f4deb. Consider uploading reports for the commit 74f4deb to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##              main   #3487      +/-   ##
==========================================
- Coverage     1.81%   0.00%   -1.82%     
- Complexity     272     299      +27     
==========================================
  Files          113      27      -86     
  Lines         6126     903    -5223     
  Branches      1479       0    -1479     
==========================================
- Hits           111       0     -111     
+ Misses        5899     903    -4996     
+ Partials       116       0     -116     
Files Changed Coverage Δ
lib/AppInfo/Application.php 0.00% <0.00%> (ø)
lib/Listener/ProfilePickerReferenceListener.php 0.00% <0.00%> (ø)
lib/Reference/ProfilePickerReferenceProvider.php 0.00% <0.00%> (ø)

... and 88 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DaphneMuller
Copy link

Moving the users_picker as it was planned with @DaphneMuller and @julien-nc.

So what is the plan? Who will maintain that code once it's been moved into this repo?

the contacts maintainers will maintain the code, but we are happy to give the team any code walk-throughs so everybody is comfortable with it.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Looks good so far!

img/profile.svg Show resolved Hide resolved
andrey18106 and others added 3 commits July 5, 2023 21:05
Co-authored-by: Christoph Wurst <ChristophWurst@users.noreply.github.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Christoph Wurst <ChristophWurst@users.noreply.github.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
@DaphneMuller
Copy link

discussed with Christoph that this issue can be merged after the icon issue is resolved (https://github.com/nextcloud/contacts/pull/3487#discussion_r1253443738)

will check with @andrey18106

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

The code looks really good but I notice two critical issues

  1. User enumeration restrictions are not valued. You can configure Nextcloud to not allow seeing other people. Yet this picker returns any user objects it can find. Ref https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/file_sharing_configuration.html#file-sharing-configuration. You can test this by restricting your local environment and entering the user ID of another user. That other user should not be selectable. You can check the sharing menu. It values all these restrictions.
  2. The user ID is used as search attribute. This works fine for database users or when LDAP records are mapped by a user-readable attribute. However, LDAP/SAML map by UUID by default. So to pick user a (LDAP UUID=597ae2f6-16a6-1027-98f4-d28b5365dc14) you have to type the exact string 597ae2f6-16a6-1027-98f4-d28b5365dc14 to find the user. See https://github.com/nextcloud/server/wiki/How-to-test-LDAP%3F for an LDAP-based user base on your dev env.

To address these two issues I would suggest using something like \OCP\Contacts\IManager::search instead of \OCP\IUserManager::get. It will allow for partial matches (andre for Andrey) and can help restrict enumeration.

'title' => $userDisplayName,
'subline' => $userEmail ?? $userDisplayName,
'email' => $userEmail,
'bio' => isset($bio) && $bio !== '' ? substr_replace($bio, '...', 80, strlen($bio)) : null,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use a multibyte-safe string function, e.g. https://www.php.net/manual/en/function.mb-substr.php and then append . substr_replace and strlen do not work well with multibytes/emojis.


$userId = $this->getObjectId($referenceText);
$user = $this->userManager->get($userId);
if ($user !== null) {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: if you invert the logic and return early for null users the method has less indentation and becomes easier to read

@DaphneMuller
Copy link

Hi @ChristophWurst , is there any chance you or your team could take it from here?

@ChristophWurst
Copy link
Member

This isn't a light change, so I'll have to allocate resources for the feature.

@ChristophWurst
Copy link
Member

@andrey18106 I see the security problems have been fixed in your repo. Could you please update this branch? Cheers

@DaphneMuller
Copy link

Maybe it's better to clarify if we actually want to proceed with this PR given the timeline this is already open?

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

Successfully merging this pull request may close these issues.

None yet

4 participants