-
Notifications
You must be signed in to change notification settings - Fork 441
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
Added parameter to disallow creating of rooms with public access #8082
Conversation
Added spreed application config parameter `public_rooms_allowed` to disallow creating of rooms with public (guest via link) access (i.e. for internal Nextcloud setups). Use ``` occ config:app:set spreed public_rooms_allowed --value 'yes' ``` to allow (default if not set) and ``` occ config:app:set spreed public_rooms_allowed --value 'no' ``` to disallow creating of rooms with public access. Related: nextcloud#521 Author-Change-Id: IB#1126215 Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
|
||
// Force group room if public room was requested and public rooms are disallowed. | ||
if (($type === Room::TYPE_PUBLIC) && ($this->config->getAppValue('spreed', 'public_rooms_allowed', 'yes') === 'no')) { | ||
$type = Room::TYPE_GROUP; |
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.
Not sure if we should simply convert it. Or just error with a 400 Bad Request and a message the clients can display.
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.
Conversion was choosen because spreed code ignores errors returned by modified functions and this seems to be safer. Conversion should never happen because function should be not available in UI also (and if bad guys will try to modify POST, will get group conversation which should not hurt regular users).
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.
That assumes all clients got updated in the meantime :)
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.
Sorry, we use web UI only - feel free to extend it for other required areas if necessary (not experienced enough in nc devel to propose it now).
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.
You can fix it with one step by moving it to RoomService::createConversation
and throwing an exception or basically adjust this list here:
spreed/lib/Service/RoomService.php
Lines 141 to 147 in 2200896
if (!\in_array($type, [ | |
Room::TYPE_GROUP, | |
Room::TYPE_PUBLIC, | |
Room::TYPE_CHANGELOG, | |
], true)) { | |
throw new InvalidArgumentException('type'); | |
} |
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.
type
is property of Room
not RoomService
so verification should take place in Room
class to avoid future problems (i.e. code outside of RoomService
will create/change room of disabled type). Seems that now Room::setType
and Room
constructor are the best places for this verification but code using it should properly handle errors when disabled type is passed. Please let me know if its possible to just throw exception in Room
methods mentioned above without messing with room type conversions (there should not be any other trash left after such exception - not sure if it would be safe now).
// Force group room if public room was requested and public rooms are disallowed. | ||
if (($type === self::TYPE_PUBLIC) && ($this->config->getAppValue('spreed', 'public_rooms_allowed', 'yes') === 'no')) { | ||
$type = self::TYPE_GROUP; | ||
} |
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.
This is not correct. You want to do this change on the RoomService, not the model.
But see comment above.
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.
Modified places where choosen to avoid problems with lack of return errors handling. If you still recommend moving it elswhere - please suggest detailed change.
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.
As per above, you should do it only in the RoomService
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.
Don't see any mention of setType
in RoomService
and this method may be called so must verify room type also.
|
||
$this->initialState->provideInitialState( | ||
'public_rooms_allowed', | ||
$this->serverConfig->getAppValue('spreed', 'public_rooms_allowed', 'yes') === 'yes' |
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.
We need to expose this to the mobile clients as a capability so they can also hide the features accordingly.
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.
This mod was created for web UI. Not experienced in nextcloud devel nor using mobile app so please suggest required changes if necessary.
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.
Basically add a line like this which in addition also checks your config:
Line 151 in 91d3bd8
$capabilities['config']['conversations']['can-create'] = $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user); |
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.
Not experienced with capabilities in Nextcloud - please create change suggestion and will just accept it to this PR or make separate PR to adjust it.
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.
tested and works 👌
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.
- Also RoomService::setType() should check the config.
- RoomController::addParticipantToRoom should not allow to add email addresses to a conversation (which also makes the room public)
- Since emails are then not allowed anymore, we should also not autocomplete them here:
shareTypes.push(SHARE.TYPE.EMAIL)
|
||
// Force group room if public room was requested and public rooms are disallowed. | ||
if (($type === Room::TYPE_PUBLIC) && ($this->config->getAppValue('spreed', 'public_rooms_allowed', 'yes') === 'no')) { | ||
$type = Room::TYPE_GROUP; |
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.
You can fix it with one step by moving it to RoomService::createConversation
and throwing an exception or basically adjust this list here:
spreed/lib/Service/RoomService.php
Lines 141 to 147 in 2200896
if (!\in_array($type, [ | |
Room::TYPE_GROUP, | |
Room::TYPE_PUBLIC, | |
Room::TYPE_CHANGELOG, | |
], true)) { | |
throw new InvalidArgumentException('type'); | |
} |
// Force group room if public room was requested and public rooms are disallowed. | ||
if (($type === self::TYPE_PUBLIC) && ($this->config->getAppValue('spreed', 'public_rooms_allowed', 'yes') === 'no')) { | ||
$type = self::TYPE_GROUP; | ||
} |
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.
As per above, you should do it only in the RoomService
|
||
$this->initialState->provideInitialState( | ||
'public_rooms_allowed', | ||
$this->serverConfig->getAppValue('spreed', 'public_rooms_allowed', 'yes') === 'yes' |
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.
Basically add a line like this which in addition also checks your config:
Line 151 in 91d3bd8
$capabilities['config']['conversations']['can-create'] = $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user); |
Verification should be placed in Room class in all methods capable of setting/changing |
…owed Fixes: a38fdfd Related: nextcloud#8082 (review) Author-Change-Id: IB#1126215 Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
4c645ce disables adding e-mails to room when public rooms are disabled. |
Sorry for the lack of responsiveness lately. |
…owed Fixes: a38fdfd Related: #8082 (review) Author-Change-Id: IB#1126215 Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
…owed Fixes: a38fdfd Related: #8082 (review) Author-Change-Id: IB#1126215 Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
Hi there, I copied your branch into our organisation and sent you an invite. I rebased it on latest master and did some fixes and changes. |
Added spreed application config parameter
public_rooms_allowed
to disallowcreating of rooms with public (guest via link) access (i.e. for internal
Nextcloud setups). Use
to allow (default if not set) and
to disallow creating of rooms with public access.
Related: #521
Author-Change-Id: IB#1126215
Signed-off-by: Pawel Boguslawski pawel.boguslawski@ib.pl