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

Allow sharing with guest users when sharing is limited by user groups #36384

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

VicDeo
Copy link
Member

@VicDeo VicDeo commented Nov 6, 2019

Description

Allow sharing with guest users when Restrict users to only share with users in their groups option is enabled

Related Issue

Motivation and Context

Guests app should not be affected by the ordinary sharing group restriction

How Has This Been Tested?

  1. Enable the guests app
  2. Check Restrict users to only share with users in their groups on the settings page
  3. Share any item with someuser@example.org (guest)

Expected

User is created, a share is added for this user. No errors

Actual

User is created, but the share is NOT added for this user. Sharing error popup in the web UI

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@VicDeo VicDeo added this to the development milestone Nov 6, 2019
@VicDeo VicDeo self-assigned this Nov 6, 2019
@codecov
Copy link

codecov bot commented Nov 6, 2019

Codecov Report

Merging #36384 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #36384      +/-   ##
============================================
+ Coverage     64.87%   64.87%   +<.01%     
- Complexity    19791    19797       +6     
============================================
  Files          1271     1272       +1     
  Lines         74733    74748      +15     
  Branches       1309     1309              
============================================
+ Hits          48480    48495      +15     
  Misses        25867    25867              
  Partials        386      386
Flag Coverage Δ Complexity Δ
#javascript 54% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 66.07% <100%> (ø) 19797 <5> (+6) ⬆️
Impacted Files Coverage Δ Complexity Δ
lib/private/Helper/UserTypeHelper.php 100% <100%> (ø) 5 <5> (?)
lib/private/Share20/Manager.php 97.15% <100%> (ø) 251 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 236e05c...ceed1f1. Read the comment docs.

@jvillafanez
Copy link
Member

We might need to consider to create a UserTypeDetection class or similar at least to move this code to a place. It isn't the first place we try to detect if a user is a guest, and it won't be the last.

@VicDeo VicDeo changed the title [WIP] Allow sharing with guest users when Restrict users to only share with users in their groups option is enabled Nov 7, 2019
@VicDeo VicDeo changed the title Allow sharing with guest users when Restrict users to only share with users in their groups option is enabled Allow sharing with guest users when sharing is limited by user groups Nov 7, 2019
@micbar
Copy link
Contributor

micbar commented Nov 7, 2019

looks promising.

Copy link
Contributor

@karakayasemi karakayasemi left a comment

Choose a reason for hiding this comment

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

I am not familiar with the Guest app concept, so I am not sure of the concept. In terms of code, rest of the things are good.

Copy link
Contributor

@karakayasemi karakayasemi left a comment

Choose a reason for hiding this comment

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

I know, it is not a big deal about performance, but if the user is a guest, no need to make any calculation about group intersection. Because of that, moving this check to one upper level is better in terms of performance.

/** @var IConfig */
private $config;

public function __construct(IAppManager $appManager = null, IConfig $config = null) {
Copy link
Member

Choose a reason for hiding this comment

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

include a comment explaining why the appManager and config can be null.

*/
public function isGuestUser($uid) {
$guestsAppEnabled = $this->appManager->isEnabledForUser('guests');
if ($guestsAppEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

should the method return true for the guest user even if the app is disabled? I find it weird that a user is reported as guest, but then, after disabling the app, the user isn't a guest any longer.

@@ -462,15 +463,19 @@ protected function validateExpirationDate(\OCP\Share\IShare $share) {
* @throws \Exception
*/
protected function userCreateChecks(\OCP\Share\IShare $share) {
$userTypeHelper = new UserTypeHelper();
Copy link
Member

Choose a reason for hiding this comment

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

this should be injected

@VicDeo VicDeo merged commit 49872a8 into master Nov 8, 2019
@delete-merged-branch delete-merged-branch bot deleted the bugfix/e3578 branch November 8, 2019 10:02
@davitol davitol mentioned this pull request Nov 26, 2019
37 tasks
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.

None yet

4 participants