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

[MM-60227] Allow plugins to ask for desktop sources for screen sharing #3135

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

streamer45
Copy link
Contributor

Summary

PR adds support for more than just Calls to ask for desktop screen-sharing sources. Since CallsWidgetWindow is a singleton, we can easily reuse most of the existing logic without having to make significant changes.

While we are here, I am also making the API call properly throw errors so that plugins can handle any permission issue without requiring them to listen to Calls-specific errors.

Note: we still expect the plugin side to implement a selection modal. I am still considering whether we should simplify this process as well, but if so it would be in another PR.

Example

desktop_sources.mp4

Ticket Link

https://mattermost.atlassian.net/browse/MM-60227

Release Note

Added support for plugins to ask for desktop source for screen sharing through the desktopAPI.getDesktopSources call

@streamer45 streamer45 added 2: Dev Review Requires review by a core committer 3: Security Review Review requested from Security Team labels Aug 28, 2024
@streamer45 streamer45 self-assigned this Aug 28, 2024
Copy link
Member

@devinbinnie devinbinnie left a comment

Choose a reason for hiding this comment

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

Was this something that already worked? I don't see any changes that allow for other windows to perform this function, unless this is just the first part of a change.

if (event.sender.id !== this.mainView?.webContentsId) {
// For Calls we make an extra check to ensure the event is coming from the expected window (main view).
// Otherwise we want to allow for other plugins to ask for screen sharing sources.
if (this.mainView && event.sender.id !== this.mainView.webContentsId) {
log.warn('handleGetDesktopSources', 'Blocked on wrong webContentsId');
Copy link
Member

Choose a reason for hiding this comment

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

If we're throwing errors here, these logs should be unnecessary as the CriticalErrorHandler should catch and log these.

Comment on lines +381 to +383
// For Calls we make an extra check to ensure the event is coming from the expected window (main view).
// Otherwise we want to allow for other plugins to ask for screen sharing sources.
if (this.mainView && event.sender.id !== this.mainView.webContentsId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was this something that already worked? I don't see any changes that allow for other windows to perform this function, unless this is just the first part of a change.

@devinbinnie The above is the logic change. It wasn't working before because we'd require the sender of the event (the requester) to be the calls widget window. Now, we only do that if the widget is actually initialized (e.g., the user has joined a call).

Copy link
Member

Choose a reason for hiding this comment

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

I'd definitely want security to weigh in on this one - since it makes it even easier for the remote code to abuse the getDesktopSources API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I am not sure we can have it both ways if the goal is to allow plugins to ask for these. It's not any less secure than what we did for Calls prior to the global widget, but it's certainly something to consider.

@@ -408,7 +408,7 @@ export class CallsWidgetWindow {

if (!await PermissionsManager.doPermissionRequest(view.webContentsId, 'screenShare', {requestingUrl: view.view.server.url.toString(), isMainFrame: false})) {
log.warn('screen share permissions disallowed', view.webContentsId, view.view.server.url.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Still don't need the extra log item here if we're throwing an error.

@amyblais amyblais removed the 3: Security Review Review requested from Security Team label Sep 12, 2024
@devinbinnie devinbinnie added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Sep 17, 2024
@amyblais amyblais added this to the v5.10.0 milestone Sep 18, 2024
@streamer45 streamer45 merged commit d4e70db into master Sep 18, 2024
11 checks passed
@streamer45 streamer45 deleted the MM-60227 branch September 18, 2024 14:49
@cwarnermm
Copy link
Member

@streamer45 - Are dev docs updates needed for this PR from your perspective?

@streamer45
Copy link
Contributor Author

@cwarnermm Not at this time. However, ideally, we should have some documentation on how plugins can integrate with our Desktop App, and this sort of functionality would fit in there. That's a larger effort, though, that likely needs to start from the eng side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request Docs/Needed release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants