Skip to content

Commit 7704f52

Browse files
[mirotalkbro] - add trust proxy, fix typo, update env
1 parent 4e8c73c commit 7704f52

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

.env.template

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ PROTOCOL=http # http or https
44
HOST=localhost
55
PORT=3016
66

7+
# Trust Proxy
8+
9+
TRUST_PROXY=false #true or false
10+
711
# Time Zone corresponding to timezone identifiers from the IANA Time Zone Database es Europe/Rome default UTC
812

913
TZ=UTC
@@ -30,7 +34,8 @@ OIDC_ISSUER_BASE_URL='https://server.example.com'
3034
OIDC_BASE_URL='http://localhost:3016' # https://bro.mirotalk.com
3135
OIDC_CLIENT_ID='ClientID'
3236
OIDC_CLIENT_SECRET='ClientSecret'
33-
OIDC_AUTH_REUIRED=false # set to true if authentication is required for all routes
37+
OIDC_AUTH_REQUIRED=false # set to true if authentication is required for all routes
38+
OIDC_AUTH_LOGOUT=true # # controls automatic logout from both your app and Auth0 when set to true
3439
SESSION_SECRET='mirotalk-bro-oidc-secret'
3540

3641
# Stun: https://bloggeek.me/webrtcglossary/stun/

app/server.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @license For open source under AGPL-3.0
99
* @license For private project or commercial purposes contact us at: [email protected]
1010
* @author Miroslav Pejic - [email protected]
11-
* @version 1.1.22
11+
* @version 1.1.23
1212
*/
1313

1414
require('dotenv').config();
@@ -110,6 +110,9 @@ if (protocol === 'http') {
110110
server = https.createServer(options, app);
111111
}
112112

113+
// Trust Proxy
114+
const trustProxy = !!getEnvBoolean(process.env.TRUST_PROXY);
115+
113116
// Cors
114117
const cors_origin = process.env.CORS_ORIGIN;
115118
const cors_methods = process.env.CORS_METHODS;
@@ -155,7 +158,7 @@ const OIDC = {
155158
scope: 'openid profile email',
156159
},
157160
authRequired: process.env.OIDC_AUTH_REQUIRED ? getEnvBoolean(process.env.OIDC_AUTH_REQUIRED) : false,
158-
auth0Logout: true,
161+
auth0Logout: process.env.OIDC_AUTH_LOGOUT ? getEnvBoolean(process.env.OIDC_AUTH_LOGOUT) : true, // Set to true to enable logout with Auth0
159162
routes: {
160163
callback: '/auth/callback',
161164
login: false,
@@ -181,6 +184,7 @@ const html = {
181184
disconnect: path.join(__dirname, '../', 'public/views/disconnect.html'),
182185
};
183186

187+
app.set('trust proxy', trustProxy); // Enables trust for proxy headers (e.g., X-Forwarded-For) based on the trustProxy setting
184188
app.use(helmet.xssFilter()); // Enable XSS protection
185189
app.use(helmet.noSniff()); // Enable content type sniffing prevention
186190
app.use(cors(corsOptions));
@@ -416,6 +420,7 @@ async function ngrokStart() {
416420
const list = await api.listTunnels();
417421
const tunnelHttps = list.tunnels[0].public_url;
418422
log.info('Server is running', {
423+
trustProxy: trustProxy,
419424
oidc: OIDC.enabled ? OIDC : false,
420425
iceServers: iceServers,
421426
cors: corsOptions,
@@ -439,6 +444,7 @@ server.listen(port, () => {
439444
ngrokStart();
440445
} else {
441446
log.info('Server is running', {
447+
trustProxy: trustProxy,
442448
oidc: OIDC.enabled ? OIDC : false,
443449
iceServers: iceServers,
444450
cors: corsOptions,

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mirotalkbro",
3-
"version": "1.1.22",
3+
"version": "1.1.23",
44
"description": "P2P WebRTC audio, video and screen live broadcast",
55
"main": "app/server.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
"author": "Miroslav Pejic",
2424
"license": "AGPLv3",
2525
"dependencies": {
26-
"@sentry/node": "^8.53.0",
26+
"@sentry/node": "^8.54.0",
2727
"compression": "^1.7.5",
2828
"cors": "^2.8.5",
2929
"dotenv": "^16.4.7",

0 commit comments

Comments
 (0)