bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/learning-dashboard/service.js

57 lines
1.7 KiB
JavaScript
Raw Normal View History

import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import Meetings from '/imports/api/meetings';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
const isModerator = () => {
const user = Users.findOne(
{
meetingId: Auth.meetingID,
userId: Auth.userID,
},
{ fields: { role: 1 } },
);
if (user && user.role === ROLE_MODERATOR) {
return true;
}
return false;
};
const getLearningDashboardAccessToken = () => ((
Meetings.findOne(
{ meetingId: Auth.meetingID, learningDashboardAccessToken: { $exists: true } },
{
fields: { learningDashboardAccessToken: 1 },
},
) || {}).learningDashboardAccessToken || null);
const setLearningDashboardCookie = () => {
const learningDashboardAccessToken = getLearningDashboardAccessToken();
if (learningDashboardAccessToken !== null) {
const lifetime = new Date();
lifetime.setTime(lifetime.getTime() + (3600000)); // 1h (extends 7d when open Dashboard)
document.cookie = `ld-${Auth.meetingID}=${getLearningDashboardAccessToken()}; expires=${lifetime.toGMTString()}; path=/`;
return true;
}
return false;
};
2021-08-27 02:04:06 +08:00
const openLearningDashboardUrl = (lang) => {
Allow BBB to run behind a proxy the avoid gUM permission queries per node The idea is to run a loadbalancer node which maps each BBB node to a path. That way each user gets only one gUM permission query for a cluster. The loadbalancer node only serves the html5 client, each BBB node will serve its own API and handle the websockets for freeswitch and bbb-webrtc-sfu. Configuring a cluster setup =========================== * let bbb-lb.example.com be the loadbalancer node * let bbb-01.eaxmple.com be a BBB node Loadbalancer ------------ On the loadbalancer node add an nginx configuration similar to this one for each BBB node: ``` location /bbb-01/html5client/ { proxy_pass https://bbb-01.example.com/bbb-01/html5client/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } ``` BBB Node -------- On the BBB node add the following options to `/etc/bigbluebutton/bbb-web.properties`: ``` defaultHTML5ClientUrl=https://bbb-lb.example.com/bbb-01/html5client/join presentationBaseURL=https://bbb-01.example.com/bigbluebutton/presentation accessControlAllowOrigin=https://bbb-lb.example.com ``` Add the following options to `/etc/bigbluebutton/bbb-html5.yml`: ``` public: app: basename: '/bbb-01/html5client' bbbWebBase: 'https://bbb-01.eaxmple.com/bigbluebutton' learningDashboardBase: 'https://bbb-01.eaxmple.com/learning-dashboard' media: stunTurnServersFetchAddress: 'https://bbb-01.eaxmple.com/bigbluebutton/api/stuns' sip_ws_host: 'bbb-01.eaxmple.com' presentation: uploadEndpoint: 'https://bbb-01.eaxmple.com/bigbluebutton/presentation/upload' ``` Create the following unit file overrides: * `/etc/systemd/system/bbb-html5-frontend@.service.d/cluster.conf` * `/etc/systemd/system/bbb-html5-backend@.service.d/cluster.conf` with the following content: ``` [Service] Environment=ROOT_URL=https://127.0.0.1/bbb-01/html5client ``` Change the nginx `$bbb_loadbalancer_node` variable to the name of the load balancer node in `/etc/bigbluebutton/nginx/loadbalancer.nginx` to allow CORS requests: ``` set $bbb_loadbalancer_node https://bbb-lb.example.com ``` Prepend the mount point of bbb-html5 in all location sections except from the `location @html5client` section in `/etc/bigbluebutton/nginx/bbb-html5.nginx` ``` location @html5client { ... } location /bbb-01/html5client/locales { ... } ```
2021-11-19 05:52:20 +08:00
const APP = Meteor.settings.public.app;
if (getLearningDashboardAccessToken() && setLearningDashboardCookie()) {
Allow BBB to run behind a proxy the avoid gUM permission queries per node The idea is to run a loadbalancer node which maps each BBB node to a path. That way each user gets only one gUM permission query for a cluster. The loadbalancer node only serves the html5 client, each BBB node will serve its own API and handle the websockets for freeswitch and bbb-webrtc-sfu. Configuring a cluster setup =========================== * let bbb-lb.example.com be the loadbalancer node * let bbb-01.eaxmple.com be a BBB node Loadbalancer ------------ On the loadbalancer node add an nginx configuration similar to this one for each BBB node: ``` location /bbb-01/html5client/ { proxy_pass https://bbb-01.example.com/bbb-01/html5client/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } ``` BBB Node -------- On the BBB node add the following options to `/etc/bigbluebutton/bbb-web.properties`: ``` defaultHTML5ClientUrl=https://bbb-lb.example.com/bbb-01/html5client/join presentationBaseURL=https://bbb-01.example.com/bigbluebutton/presentation accessControlAllowOrigin=https://bbb-lb.example.com ``` Add the following options to `/etc/bigbluebutton/bbb-html5.yml`: ``` public: app: basename: '/bbb-01/html5client' bbbWebBase: 'https://bbb-01.eaxmple.com/bigbluebutton' learningDashboardBase: 'https://bbb-01.eaxmple.com/learning-dashboard' media: stunTurnServersFetchAddress: 'https://bbb-01.eaxmple.com/bigbluebutton/api/stuns' sip_ws_host: 'bbb-01.eaxmple.com' presentation: uploadEndpoint: 'https://bbb-01.eaxmple.com/bigbluebutton/presentation/upload' ``` Create the following unit file overrides: * `/etc/systemd/system/bbb-html5-frontend@.service.d/cluster.conf` * `/etc/systemd/system/bbb-html5-backend@.service.d/cluster.conf` with the following content: ``` [Service] Environment=ROOT_URL=https://127.0.0.1/bbb-01/html5client ``` Change the nginx `$bbb_loadbalancer_node` variable to the name of the load balancer node in `/etc/bigbluebutton/nginx/loadbalancer.nginx` to allow CORS requests: ``` set $bbb_loadbalancer_node https://bbb-lb.example.com ``` Prepend the mount point of bbb-html5 in all location sections except from the `location @html5client` section in `/etc/bigbluebutton/nginx/bbb-html5.nginx` ``` location @html5client { ... } location /bbb-01/html5client/locales { ... } ```
2021-11-19 05:52:20 +08:00
window.open(`${APP.learningDashboardBase}/?meeting=${Auth.meetingID}&lang=${lang}`, '_blank');
} else {
Allow BBB to run behind a proxy the avoid gUM permission queries per node The idea is to run a loadbalancer node which maps each BBB node to a path. That way each user gets only one gUM permission query for a cluster. The loadbalancer node only serves the html5 client, each BBB node will serve its own API and handle the websockets for freeswitch and bbb-webrtc-sfu. Configuring a cluster setup =========================== * let bbb-lb.example.com be the loadbalancer node * let bbb-01.eaxmple.com be a BBB node Loadbalancer ------------ On the loadbalancer node add an nginx configuration similar to this one for each BBB node: ``` location /bbb-01/html5client/ { proxy_pass https://bbb-01.example.com/bbb-01/html5client/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } ``` BBB Node -------- On the BBB node add the following options to `/etc/bigbluebutton/bbb-web.properties`: ``` defaultHTML5ClientUrl=https://bbb-lb.example.com/bbb-01/html5client/join presentationBaseURL=https://bbb-01.example.com/bigbluebutton/presentation accessControlAllowOrigin=https://bbb-lb.example.com ``` Add the following options to `/etc/bigbluebutton/bbb-html5.yml`: ``` public: app: basename: '/bbb-01/html5client' bbbWebBase: 'https://bbb-01.eaxmple.com/bigbluebutton' learningDashboardBase: 'https://bbb-01.eaxmple.com/learning-dashboard' media: stunTurnServersFetchAddress: 'https://bbb-01.eaxmple.com/bigbluebutton/api/stuns' sip_ws_host: 'bbb-01.eaxmple.com' presentation: uploadEndpoint: 'https://bbb-01.eaxmple.com/bigbluebutton/presentation/upload' ``` Create the following unit file overrides: * `/etc/systemd/system/bbb-html5-frontend@.service.d/cluster.conf` * `/etc/systemd/system/bbb-html5-backend@.service.d/cluster.conf` with the following content: ``` [Service] Environment=ROOT_URL=https://127.0.0.1/bbb-01/html5client ``` Change the nginx `$bbb_loadbalancer_node` variable to the name of the load balancer node in `/etc/bigbluebutton/nginx/loadbalancer.nginx` to allow CORS requests: ``` set $bbb_loadbalancer_node https://bbb-lb.example.com ``` Prepend the mount point of bbb-html5 in all location sections except from the `location @html5client` section in `/etc/bigbluebutton/nginx/bbb-html5.nginx` ``` location @html5client { ... } location /bbb-01/html5client/locales { ... } ```
2021-11-19 05:52:20 +08:00
window.open(`${APP.learningDashboardBase}/?meeting=${Auth.meetingID}&sessionToken=${Auth.sessionToken}&lang=${lang}`, '_blank');
}
};
export default {
isModerator,
getLearningDashboardAccessToken,
setLearningDashboardCookie,
openLearningDashboardUrl,
};