[mirotalksfu] - Enable OIDC authentication in conjunction with Host protection mode

هذا الالتزام موجود في:
Miroslav Pejic
2024-05-06 13:13:46 +02:00
الأصل 4c635196b3
التزام 240670100c
6 ملفات معدلة مع 103 إضافات و17 حذوفات

عرض الملف

@@ -6,6 +6,15 @@ module.exports = class Host {
this.roomActive = false;
}
/**
* Get IP from req
* @param {object} req
* @returns string IP
*/
getIP(req) {
return req.headers['x-forwarded-for'] || req.headers['X-Forwarded-For'] || req.socket.remoteAddress || req.ip;
}
/**
* Get authorized IPs
* @returns object
@@ -21,7 +30,7 @@ module.exports = class Host {
*/
setAuthorizedIP(ip, authorized) {
this.authorizedIPs.set(ip, authorized);
this.roomActive = true;
this.setRoomActive();
}
/**
@@ -34,20 +43,34 @@ module.exports = class Host {
}
/**
* Host room active
* Host room status
* @returns boolean
*/
isRoomActive() {
return this.roomActive;
}
/**
* Set host room activate
*/
setRoomActive() {
this.roomActive = true;
}
/**
* Set host room deactivate
*/
setRoomDeactivate() {
this.roomActive = false;
}
/**
* Delete ip from authorized IPs
* @param {string} ip
* @returns boolean
*/
deleteIP(ip) {
this.roomActive = false;
this.setRoomDeactivate();
return this.authorizedIPs.delete(ip);
}
};