From 6da22eb46cf2c0791bbf5721c31bf288723e7d03 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sat, 1 Feb 2025 00:17:11 +0100 Subject: [PATCH] [mirotalksfu] - Enable OIDC support for alias domains with dynamic baseURL --- app/src/Server.js | 31 +++++++++++++++++++++++-------- package.json | 2 +- public/js/Brand.js | 2 +- public/js/Room.js | 4 ++-- public/js/RoomClient.js | 2 +- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/src/Server.js b/app/src/Server.js index 1372ac88..bf76c7b2 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -58,7 +58,7 @@ dev dependencies: { * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.7.21 + * @version 1.7.22 * */ @@ -414,14 +414,29 @@ function startServer() { } }); - // OpenID Connect + // OpenID Connect - Dynamically set baseURL based on incoming host and protocol if (OIDC.enabled) { - try { - app.use(auth(OIDC.config)); - } catch (err) { - log.error(err); - process.exit(1); - } + const getDynamicConfig = (host, protocol) => { + const baseURL = `${protocol}://${host}`; + log.debug('OIDC baseURL', baseURL); + return { + ...OIDC.config, + baseURL, + }; + }; + + // Apply the authentication middleware using dynamic baseURL configuration + app.use((req, res, next) => { + const host = req.headers.host; + const protocol = req.protocol === 'https' ? 'https' : 'http'; + const dynamicOIDCConfig = getDynamicConfig(host, protocol); + try { + auth(dynamicOIDCConfig)(req, res, next); + } catch (err) { + log.error('OIDC Auth Middleware Error', err); + process.exit(1); + } + }); } // Route to display user information diff --git a/package.json b/package.json index 53d7c2c1..360b0b54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalksfu", - "version": "1.7.21", + "version": "1.7.22", "description": "WebRTC SFU browser-based video calls", "main": "Server.js", "scripts": { diff --git a/public/js/Brand.js b/public/js/Brand.js index f7e9128f..144963cd 100644 --- a/public/js/Brand.js +++ b/public/js/Brand.js @@ -64,7 +64,7 @@ let BRAND = { }, about: { imageUrl: '../images/mirotalk-logo.gif', - title: 'WebRTC SFU v1.7.21', + title: 'WebRTC SFU v1.7.22', html: `