[mirotalksfu] - #160 fetch peer_name from OIDC profile
هذا الالتزام موجود في:
@@ -55,7 +55,7 @@ dev dependencies: {
|
|||||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
* @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
|
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||||
* @version 1.6.27
|
* @version 1.6.28
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -395,9 +395,22 @@ function startServer() {
|
|||||||
// Route to display user information
|
// Route to display user information
|
||||||
app.get('/profile', OIDCAuth, (req, res) => {
|
app.get('/profile', OIDCAuth, (req, res) => {
|
||||||
if (OIDC.enabled) {
|
if (OIDC.enabled) {
|
||||||
return res.json(req.oidc.user); // Send user information as JSON
|
const user = { ...req.oidc.user };
|
||||||
|
user.peer_name = {
|
||||||
|
force: OIDC.peer_name?.force || false,
|
||||||
|
email: OIDC.peer_name?.email || false,
|
||||||
|
name: OIDC.peer_name?.name || false,
|
||||||
|
};
|
||||||
|
log.debug('OIDC get Profile', user);
|
||||||
|
return res.json(user);
|
||||||
}
|
}
|
||||||
res.sendFile(views.notFound);
|
// OIDC disabled
|
||||||
|
res.status(201).json({
|
||||||
|
email: false,
|
||||||
|
name: false,
|
||||||
|
peer_name: false,
|
||||||
|
message: 'Profile not found because OIDC is disabled',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Authentication Callback Route
|
// Authentication Callback Route
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ module.exports = {
|
|||||||
For those seeking an open-source solution, check out: https://github.com/panva/node-oidc-provider
|
For those seeking an open-source solution, check out: https://github.com/panva/node-oidc-provider
|
||||||
*/
|
*/
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
peer_name: {
|
||||||
|
force: true, // Enforce using profile data for peer_name
|
||||||
|
email: true, // Use email as peer_name
|
||||||
|
name: false, // Don't use full name (family_name + given_name)
|
||||||
|
},
|
||||||
config: {
|
config: {
|
||||||
issuerBaseURL: 'https://server.example.com',
|
issuerBaseURL: 'https://server.example.com',
|
||||||
baseURL: `http://localhost:${process.env.PORT ? process.env.PORT : 3010}`, // https://sfu.mirotalk.com
|
baseURL: `http://localhost:${process.env.PORT ? process.env.PORT : 3010}`, // https://sfu.mirotalk.com
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mirotalksfu",
|
"name": "mirotalksfu",
|
||||||
"version": "1.6.27",
|
"version": "1.6.28",
|
||||||
"description": "WebRTC SFU browser-based video calls",
|
"description": "WebRTC SFU browser-based video calls",
|
||||||
"main": "Server.js",
|
"main": "Server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
|
|||||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
* @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
|
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||||
* @version 1.6.27
|
* @version 1.6.28
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -996,6 +996,34 @@ async function whoAreYou() {
|
|||||||
|
|
||||||
initUser.classList.toggle('hidden');
|
initUser.classList.toggle('hidden');
|
||||||
|
|
||||||
|
// Fetch the OIDC profile and manage peer_name
|
||||||
|
let force_peer_name = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data: profile } = await axios.get('/profile', { timeout: 5000 });
|
||||||
|
|
||||||
|
if (profile) {
|
||||||
|
console.log('AXIOS GET OIDC Profile retrieved successfully', profile);
|
||||||
|
|
||||||
|
// Define peer_name based on the profile properties and preferences
|
||||||
|
const peerNamePreference = profile.peer_name || {};
|
||||||
|
default_name =
|
||||||
|
(peerNamePreference.email && profile.email) || (peerNamePreference.name && profile.name) || null;
|
||||||
|
|
||||||
|
// Set localStorage and force_peer_name if applicable
|
||||||
|
if (default_name && peerNamePreference.force) {
|
||||||
|
window.localStorage.peer_name = default_name;
|
||||||
|
force_peer_name = true;
|
||||||
|
} else {
|
||||||
|
console.warn('AXIOS GET Profile retrieved but missing required peer name fields');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('AXIOS GET Profile data is empty or undefined');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('AXIOS OIDC Error fetching profile', error.message || error);
|
||||||
|
}
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
allowOutsideClick: false,
|
allowOutsideClick: false,
|
||||||
allowEscapeKey: false,
|
allowEscapeKey: false,
|
||||||
@@ -1034,6 +1062,11 @@ async function whoAreYou() {
|
|||||||
joinRoom(peer_name, room_id);
|
joinRoom(peer_name, room_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (force_peer_name) {
|
||||||
|
getId('usernameInput').disabled = true;
|
||||||
|
getId('initUsernameEmojiButton').disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isVideoAllowed) {
|
if (!isVideoAllowed) {
|
||||||
elemDisplay('initVideo', false);
|
elemDisplay('initVideo', false);
|
||||||
initVideoContainerShow(false);
|
initVideoContainerShow(false);
|
||||||
@@ -4503,6 +4536,7 @@ function adaptAspectRatio(participantsCount) {
|
|||||||
// desktop aspect ratio
|
// desktop aspect ratio
|
||||||
switch (participantsCount) {
|
switch (participantsCount) {
|
||||||
case 1:
|
case 1:
|
||||||
|
//case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
case 7:
|
case 7:
|
||||||
@@ -4564,7 +4598,7 @@ function showAbout() {
|
|||||||
imageUrl: image.about,
|
imageUrl: image.about,
|
||||||
customClass: { image: 'img-about' },
|
customClass: { image: 'img-about' },
|
||||||
position: 'center',
|
position: 'center',
|
||||||
title: 'WebRTC SFU v1.6.27',
|
title: 'WebRTC SFU v1.6.28',
|
||||||
html: `
|
html: `
|
||||||
<br />
|
<br />
|
||||||
<div id="about">
|
<div id="about">
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم