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

Add support for JaaS #185

Closed
wants to merge 12 commits into from

Conversation

theunafraid
Copy link

@theunafraid theunafraid commented Mar 18, 2021

Hi everyone,

Summary

This pull request adds support for Jitsi as a Service.

The added code will generate a JaaS JWT for meetings. Mattermost users are moderators while non users are handled as guests.
To add mutually exclusive Jitsi/JaaS option had to create a custom setting for the admin console which is compatible with current version. The previous settings are moved to JitsiSettings key and a few more added for JaaS. The jitsiembedded setting is used by both the Jitsi and JaaS version. JitsiSettings component was added for future improvements and mutual exclusivity selection Jitsi/JaaS. When the user upgrades the Jitsi settings should be imported from the previous version. Jitsi server and client code was reused for JaaS except in cases where the client runs outside of Mattermost UI(open in new tab).

If user enables JaaS for this version has to setup Branding, AppID, ApiKey and RSA keys as shown in the JaaS Api Key tutorial and for more info JaaS Start Guide. After following the Api Key tutorial (no code), branding can be done by going to JaaS Branding where the invite URL can be customised for example: https://mymattermostdomain.com/plugins/jitsi/api/v1/meetings, must include /plugins/jitsi/api/v1/meetings. The AppID, ApiKey and RSA private key can be copied in the admin console https://mymattermostdomain.com/admin_console/plugins/plugin_jitsi if JaaS is enabled.

Ticket Link

Fixes #183

@theunafraid theunafraid requested a review from larkox as a code owner March 18, 2021 17:00
@larkox larkox requested a review from jespino March 22, 2021 12:28
@larkox larkox added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Mar 22, 2021
@codecov-io
Copy link

Codecov Report

Merging #185 (25e30b6) into master (e5e3252) will decrease coverage by 11.83%.
The diff coverage is 4.01%.

❗ Current head 25e30b6 differs from pull request most recent head b903bb9. Consider uploading reports for the commit b903bb9 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           master     #185       +/-   ##
===========================================
- Coverage   44.95%   33.12%   -11.84%     
===========================================
  Files           7        7               
  Lines         803     1105      +302     
===========================================
+ Hits          361      366        +5     
- Misses        417      710      +293     
- Partials       25       29        +4     
Impacted Files Coverage Δ
server/api.go 0.00% <0.00%> (ø)
server/command.go 60.08% <ø> (ø)
server/manifest.go 100.00% <ø> (ø)
server/configuration.go 7.46% <2.94%> (-6.83%) ⬇️
server/plugin.go 43.03% <7.10%> (-18.39%) ⬇️

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 e5e3252...b903bb9. Read the comment docs.

server/api.go Outdated Show resolved Hide resolved
server/api.go Outdated
@@ -80,6 +229,11 @@ func (p *Plugin) handleConfig(w http.ResponseWriter, r *http.Request) {
}

func (p *Plugin) handleExternalAPIjs(w http.ResponseWriter, r *http.Request) {
if p.getConfiguration().UseJaaS {
p.proxyExternalAPIjsJaaS(w, r)
Copy link
Contributor

Choose a reason for hiding this comment

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

We were more include to use a javascript file that is under control to avoid that a security issue in the JaaS service propagates some how in to the mattermost service. @jupenur any opinion here?

server/command.go Outdated Show resolved Hide resolved
webapp/package.json Outdated Show resolved Hide resolved
</label>
<div className='help-text'>
<span>
{'(Insecure) If your Jitsi server is not compatible with this plugin, include the JavaScript API hosted on your Jitsi server directly in Mattermost instead of the default API version provided by the plugin. WARNING: Enabling this setting can compromise the security of your Mattermost system, if your Jitsi server is not fully trusted and allows direct modification of program files. Use with caution.'}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love to have all this texts translated.

Copy link
Author

Choose a reason for hiding this comment

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

I would love to have all this texts translated.

To add translations for these texts i have to use the Mattermost translation server right? https://translate.mattermost.com/projects/i18n-wip/mattermost-webapp-wip/

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really, we haven't integrated the plugin itself with our weblate, it is just marking the text as translatable (like in other places) and adding the string to the i18n/en.json file.

checked={!this.props.embedded}
onChange={this.props.onJitsiCompatibilityChange}
/>
<span>{'false'}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like more like a label for the input

Copy link
Contributor

Choose a reason for hiding this comment

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

@jespino What exactly are you expecting here?

Copy link
Contributor

@jespino jespino left a comment

Choose a reason for hiding this comment

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

My main concern is about the usage of an external javascript file that can be modified by an attacker and can lead into security problem in our side, I going to wait for the @jupenur opinion here, but I expect we want a similar to the already applied one. If you enable JaaS, use a plugin copy of the js file, unless you enable the Compatiblity Mode, that would use the external one. Other than that, another set of comments, but if QA passes it properly and @larkox approve it to. I would love to merge it.

@jespino
Copy link
Contributor

jespino commented Mar 26, 2021

@theunafraid one question, is there any difference between the external api script from the jitsi installation and the Jaas one?

@theunafraid
Copy link
Author

@theunafraid one question, is there any difference between the external api script from the jitsi installation and the Jaas one?

From what i know, the version JaaS version may contain updates that may not be on meet.jit.si but maybe i'm wrong, have to check with someone else.

@saghul
Copy link

saghul commented Mar 31, 2021

unafraid one question, is there any difference between the external api script from the jitsi installation and the Jaas one?

No difference, they are exactly the same. Usually using a bundled version works, but sometimes an update is necessary. Right now I'm pretty sure copying the meeting link (with the button) is broken in Mattermost because we need to pass a new allow directive to the iframe. This is requires an updated bundle.

Regarding the external JS file. I understand the concern. I think there are 2 ways to go about it:

  • Treat 8x8.vc as a trusted source, JaaS customers are already trusting it with their meetings after all.
  • Honor the setting also on JaaS, but recommend it be disabled with a note in the settings panel.

Given the simple use of the API the plugin uses, I'd say we could start either way and adapt as needed once it starts to see some use.

@jespino
Copy link
Contributor

jespino commented Mar 31, 2021

@saghul @theunafraid ok, then my proposal is to update the file that is bundled with mattermost, and allow to configure the "Compatibility mode" (it does exactly that, instead of using the copy, we proxy the jitsi server file).

Our policy is "secure by default" so the default configuration should be to use our copy of the file.

The main problem in security is. If somebody enter in your system and is able to modify that file, automatically can load arbitrary javascript in our application under our same domain, giving access to session information. That means, enabling this, the surface of attack is the union of both products, and one if them is completely out of our control.

@saghul
Copy link

saghul commented Mar 31, 2021

Sounds good @jespino. @theunafraid can you please make those changes?

@theunafraid
Copy link
Author

Sounds good @jespino. @theunafraid can you please make those changes?

Sure, i'll take care of it.

@theunafraid theunafraid reopened this Mar 31, 2021
@saghul
Copy link

saghul commented Apr 21, 2021

@jespino Compatibility mode should be restored now. Can you please take another look?

@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2021

Codecov Report

Merging #185 (91b667e) into master (e5e3252) will decrease coverage by 11.89%.
The diff coverage is 4.01%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #185       +/-   ##
===========================================
- Coverage   44.95%   33.06%   -11.90%     
===========================================
  Files           7        6        -1     
  Lines         803     1104      +301     
===========================================
+ Hits          361      365        +4     
- Misses        417      710      +293     
- Partials       25       29        +4     
Impacted Files Coverage Δ
server/api.go 0.00% <0.00%> (ø)
server/configuration.go 7.46% <2.94%> (-6.83%) ⬇️
server/plugin.go 43.03% <7.10%> (-18.39%) ⬇️

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 e5e3252...91b667e. Read the comment docs.

@saghul
Copy link

saghul commented May 20, 2021

👋 @jespino Any chance we can get this moved forward?

Copy link
Contributor

@larkox larkox left a comment

Choose a reason for hiding this comment

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

Thank you for your patience. I took longer than I expected to review this.

The only blocking issue is the first one, but I have more questions here and there.

plugin.json Outdated Show resolved Hide resolved
server/api.go Show resolved Hide resolved
server/api.go Show resolved Hide resolved
server/api.go Show resolved Hide resolved
server/plugin.go Show resolved Hide resolved
server/plugin.go Outdated Show resolved Hide resolved
webapp/src/jaas/reducers/index.ts Outdated Show resolved Hide resolved
webapp/src/components/admin_settings/jitsi_settings.tsx Outdated Show resolved Hide resolved
@larkox larkox requested a review from jespino June 8, 2021 08:47
@theunafraid
Copy link
Author

@larkox @DHaussermann I've added manifest.go, it seems to be ok.

@larkox
Copy link
Contributor

larkox commented Jul 27, 2021

@theunafraid I think that running make apply will generate both the go and ts manifests which were removed for some reason in this PR (maybe due to the merge). Could you try?

@theunafraid
Copy link
Author

@theunafraid I think that running make apply will generate both the go and ts manifests which were removed for some reason in this PR (maybe due to the merge). Could you try?

Yes, that was my assumption, i ran make apply but i did not add the ts manifest, will add it now. I thought those files should not be added.

@aaronrothschild aaronrothschild added this to the v2.1.0 milestone Aug 12, 2021
@appcoders
Copy link

When will this be merged? Thanks :-)

@larkox
Copy link
Contributor

larkox commented Nov 25, 2021

@DHaussermann Do you know when will you be able to test this one?

@DHaussermann
Copy link

@dipak-demansol I have been struggling to find time for this PR. Let's follow up on this change and see if it's something we can have you review instead.

@dipak-demansol dipak-demansol self-requested a review December 7, 2021 06:18
@dipak-demansol dipak-demansol removed their request for review January 19, 2022 15:18
@hanzei hanzei modified the milestones: v2.1.0, v2.2.0 Jan 21, 2022
@hanzei
Copy link
Contributor

hanzei commented Jan 24, 2022

@theunafraid Could you please merge master into your PR?

@hanzei hanzei modified the milestones: v2.2.0, v2.1.0 Jan 25, 2022
@hanzei hanzei requested a review from dipak-demansol January 25, 2022 14:41
@hanzei
Copy link
Contributor

hanzei commented Jan 25, 2022

@dipak-demansol Maybe you can help with testing this PR? Not a high priority.

@DHaussermann
Copy link

Hi @theunafraid,
@dipak-demansol attempted to test this but it was not functional. Perhaps you could help with a couple questions?

  1. Does generating the key have to occur directly on the MM server directly? I believe Dipak may have generated the key locally and then uploaded using the UI provided
    image
    image

  2. When attempting to use the plgin the web shows a 500 error and the logs show

{"timestamp":"2022-04-04 13:18:45.350 Z","level":"error","msg":"","caller":"web/context.go:105","path":"/api/v4/commands/execute","request_id":"7gdxef5isbdgtx3ougpnnz3cxo","ip_addr":"1x.xxxx.xxx8","user_id":"6enjudxerp8j5eqqe9xw5x569r","method":"POST","err_where":"","http_code":500,"err_details":"startMeeting() threw error: <nil>"}

Can you provide any insight into what may have occurred here or some isolation steps?

  1. @aaronrothschild we may need UX input here. The UI may be a counter intuitive. We might be able to add a field label or make it morew clear that the top radio will switch all the fields.
    image

@aaronrothschild
Copy link
Contributor

Yes, there should be a setting Label asking "Which type of Jitsi server will you be using?" then show those 2 options.

@DHaussermann
Copy link

DHaussermann commented Apr 8, 2022

Does generating the key have to occur directly on the MM server directly?

As per @dipak-demansol the same issue still occurs when creating the token directly on the MM server.

@hanzei hanzei removed the request for review from dipak-demansol December 2, 2022 15:23
@hanzei
Copy link
Contributor

hanzei commented Dec 2, 2022

Closing in favor of #219

@hanzei hanzei closed this Dec 2, 2022
@hanzei hanzei added Lifecycle/3:orphaned and removed 3: QA Review Requires review by a QA tester labels Dec 2, 2022
@hanzei hanzei removed this from the v2.1.0 milestone Dec 2, 2022
@hanzei hanzei removed the request for review from DHaussermann December 2, 2022 15:23
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.

JWT Configuration with Jaas