Skip to content

Commit 87ba47e

Browse files
committed
Force console https
1 parent a9960b8 commit 87ba47e

File tree

4 files changed

+64
-25
lines changed

4 files changed

+64
-25
lines changed

backend/managers/openstack.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,20 @@ async function restartInstance(provider, instance, hard = false) {
453453
}
454454
}
455455

456+
/**
457+
* Force HTTPS for console URLs to prevent mixed content errors
458+
*/
459+
function forceHttpsForConsoleUrl(url, consoleType) {
460+
if (!url) return url;
461+
462+
// Force HTTPS for VNC/NoVNC URLs to prevent mixed content errors
463+
if ((consoleType.toUpperCase() === 'VNC' || consoleType.toUpperCase() === 'NOVNC') && url.startsWith('http://')) {
464+
url = url.replace('http://', 'https://');
465+
}
466+
467+
return url;
468+
}
469+
456470
/**
457471
* Get console URL for instance
458472
*/
@@ -494,6 +508,9 @@ async function getConsoleUrl(provider, instance, consoleType = 'NOVNC') {
494508

495509
let consoleUrl = response.remote_console?.url;
496510

511+
// Force HTTPS for VNC URLs to prevent mixed content errors
512+
consoleUrl = forceHttpsForConsoleUrl(consoleUrl, consoleType);
513+
497514
// Add auto-scaling to NoVNC URLs like compsole does
498515
if ((consoleType.toUpperCase() === 'VNC' || consoleType.toUpperCase() === 'NOVNC') && consoleUrl && !consoleUrl.includes('scale=true')) {
499516
consoleUrl += '&scale=true';
@@ -547,6 +564,9 @@ async function getConsoleUrlForProject(provider, projectName, instance, consoleT
547564

548565
let consoleUrl = response.remote_console?.url;
549566

567+
// Force HTTPS for VNC URLs to prevent mixed content errors
568+
consoleUrl = forceHttpsForConsoleUrl(consoleUrl, consoleType);
569+
550570
// Add auto-scaling to NoVNC URLs like compsole does
551571
if ((consoleType.toUpperCase() === 'VNC' || consoleType.toUpperCase() === 'NOVNC') && consoleUrl && !consoleUrl.includes('scale=true')) {
552572
consoleUrl += '&scale=true';

backend/routes/admin.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,19 @@ const { v4: uuidv4 } = require('uuid');
117117
* type: boolean
118118
* description: Whether the workshop is currently locked
119119
* nextAction:
120-
* type: object
121-
* nullable: true
122-
* properties:
123-
* type:
124-
* type: string
125-
* enum: [lock, unlock]
126-
* description: Type of next action
127-
* at:
128-
* type: string
129-
* format: date-time
130-
* description: When the next action will occur
120+
* oneOf:
121+
* - type: object
122+
* properties:
123+
* type:
124+
* type: string
125+
* enum: [lock, unlock]
126+
* description: Type of next action
127+
* at:
128+
* type: string
129+
* format: date-time
130+
* description: When the next action will occur
131+
* required: [type, at]
132+
* - type: "null"
131133
*/
132134

133135
/**
@@ -979,17 +981,19 @@ router.post('/workshops/:id/unlock', authenticateToken, requireAdmin, async (req
979981
* type: boolean
980982
* description: Whether the workshop is currently locked
981983
* nextAction:
982-
* type: object
983-
* nullable: true
984-
* properties:
985-
* type:
986-
* type: string
987-
* enum: [lock, unlock]
988-
* description: Type of next action
989-
* at:
990-
* type: string
991-
* format: date-time
992-
* description: When the next action will occur
984+
* oneOf:
985+
* - type: object
986+
* properties:
987+
* type:
988+
* type: string
989+
* enum: [lock, unlock]
990+
* description: Type of next action
991+
* at:
992+
* type: string
993+
* format: date-time
994+
* description: When the next action will occur
995+
* required: [type, at]
996+
* - type: "null"
993997
* 500:
994998
* description: Internal server error
995999
* content:
@@ -1070,7 +1074,6 @@ router.get('/lockouts', authenticateToken, requireAdmin, async (req, res) => {
10701074
* /api/admin/logs/cleanup:
10711075
* post:
10721076
* summary: Clean up old logs
1073-
* description: Deletes logs older than a specified number of days (default: 7 days)
10741077
* tags: [Admin]
10751078
* security:
10761079
* - BearerAuth: []

frontend/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<link rel="icon" href="/icon.png">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
78
<title>Wiretap - CCSO Competition Platform</title>
89
<meta name="description" content="Wiretap is the CCSO Competition Platform. It is a platform for the CCSO to manage their competitions and instances.">
910
<!-- Runtime environment configuration -->

frontend/src/views/Console.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@
176176
>
177177
<!-- VNC Console iframe -->
178178
<iframe
179-
v-if="consoleUrl"
180-
:src="consoleUrl"
179+
v-if="secureConsoleUrl"
180+
:src="secureConsoleUrl"
181181
class="w-full h-full border-0"
182182
allowfullscreen
183183
frameborder="0"
184184
scrolling="no"
185+
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals"
186+
referrerpolicy="no-referrer"
185187
></iframe>
186188
<div v-else class="w-full h-full flex items-center justify-center text-green-400 font-mono text-sm">
187189
<div class="text-center">
@@ -336,6 +338,18 @@ export default {
336338
type: 'success'
337339
})
338340
341+
// Ensure console URL is always HTTPS to prevent mixed content errors
342+
const secureConsoleUrl = computed(() => {
343+
if (!consoleUrl.value) return ''
344+
345+
// Force HTTPS for VNC console URLs to prevent mixed content errors
346+
if (consoleUrl.value.startsWith('http://')) {
347+
return consoleUrl.value.replace('http://', 'https://')
348+
}
349+
350+
return consoleUrl.value
351+
})
352+
339353
const isLocked = computed(() => {
340354
if (user.value?.role === 'ADMIN' || user.value?.role === 'admin') return false
341355
return instance.value?.locked || false
@@ -612,6 +626,7 @@ export default {
612626
isRebootMenuOpen,
613627
consoleContainer,
614628
consoleUrl,
629+
secureConsoleUrl,
615630
isLocked,
616631
canShowConsole,
617632
isFullscreenRoute,

0 commit comments

Comments
 (0)