Skip to content

Commit

Permalink
Added OCR HTTP Basic Auth support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Oct 21, 2022
1 parent f37fbbe commit 8d83c1b
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1661,18 +1661,7 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
<div>Boot Settings</div>
</div>
<div style=height:26px>
<select id="idx_d24ForceBootDevice" style="float:right;width:200px" onchange=showAdvPowerDlgChange()>
<option value=0>None</option>
<option id="ForceDVDBootOption" value=1>Force CD/DVD Boot</option>
<option id="ForcePXEBootOption" value=2>Force PXE Boot</option>
<option id="ForceHDBootOption" value=3>Force Hard Disk Boot</option>
<option id="ForceDiagBootOption" value=4>Force Diagnostic Boot</option>
<!-- ###BEGIN###{PowerControl-OneClick} -->
<option id="ForceUEFIBootOption" value=5>Force OCR UEFI Boot Option</option>
<option id="ForceHttpBootOption" value=6>Force OCR UEFI HTTPS Boot (.iso)</option>
<option id="ForceHttpUrlBootOption" value=7>Force OCR UEFI HTTPS Boot (url)</option>
<!-- ###END###{PowerControl-OneClick} -->
</select>
<select id="idx_d24ForceBootDevice" style="float:right;width:200px" onchange=showAdvPowerDlgChange()></select>
<div>Boot Source</div>
</div>
<div id="idx_d24bootSource" style=height:26px>
Expand Down Expand Up @@ -10911,6 +10900,9 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
function showAdvPowerDlg() {
try { Q('idx_d24Command').value = (amtsysstate['CIM_ServiceAvailableToElement'].responses[0]['PowerState'] == 2)?10:2; } catch (ex) { }

// Available force boot options
var forceBootDeviceOptions = '<option value=0>None</option><option id="ForceDVDBootOption" value=1>Force CD/DVD Boot</option><option id="ForcePXEBootOption" value=2>Force PXE Boot</option><option id="ForceHDBootOption" value=3>Force Hard Disk Boot</option><option id="ForceDiagBootOption" value=4>Force Diagnostic Boot</option>';

// Show boot capabilities
QV('d24dBiosPause', amtPowerBootCapabilities['BIOSPause'] == true);
QV('d24dBiosSecureBoot', amtPowerBootCapabilities['BIOSSecureBoot'] == true);
Expand All @@ -10923,17 +10915,15 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
//QV('', amtPowerBootCapabilities['ForceWinREBoot'] == true);
QV('ForcePXEBootOption', amtPowerBootCapabilities['ForcePXEBoot'] == true);
// ###BEGIN###{PowerControl-OneClick}
QV('ForceUEFIBootOption', false);
if ((AmtOcrPbaLength > 0) && (amtPowerBootCapabilities['ForceUEFIPBABoot'] == true)) {
QV('ForceUEFIBootOption', true);
forceBootDeviceOptions += '<option id="ForceUEFIBootOption" value=5>Force OCR UEFI Boot Option</option>';
var x = '';
for (var i in AmtOcrPba) { x += '<option value=' + i + '>' + AmtOcrPba[i].instance + '</option>'; }
QH('idx_d24customBootMediaIndex', x);
}
var httpsBootPossible = (meshCentralServer==null && wsstack.comm.xtlsCertificate != null) || (meshCentralServer!=null && ((currentcomputer.conn & 4) == 4) && currentcomputer.tls == 1) || (meshCentralServer!=null && ((currentcomputer.conn & 2) == 2) )

QV('ForceHttpBootOption', (amtPowerBootCapabilities['ForceUEFIHTTPSBoot'] == true) && httpsBootPossible);
QV('ForceHttpUrlBootOption', (amtPowerBootCapabilities['ForceUEFIHTTPSBoot'] == true) && httpsBootPossible);
var httpsBootPossible = ((meshCentralServer == null) && (wsstack.comm.xtlsCertificate != null)) || (meshCentralServer!=null && ((currentcomputer.conn & 4) == 4) && currentcomputer.tls == 1) || (meshCentralServer!=null && ((currentcomputer.conn & 2) == 2) )
if ((amtPowerBootCapabilities['ForceUEFIHTTPSBoot'] == true) && httpsBootPossible) { forceBootDeviceOptions += '<option id="ForceHttpBootOption" value=6>Force OCR UEFI HTTPS Boot (.iso)</option>'; }
if ((amtPowerBootCapabilities['ForceUEFIHTTPSBoot'] == true) && httpsBootPossible) { forceBootDeviceOptions += '<option id="ForceHttpUrlBootOption" value=7>Force OCR UEFI HTTPS Boot (url)</option>'; }
// ###END###{PowerControl-OneClick}
QV('d24dForceProgressEvents', amtPowerBootCapabilities['ForcedProgressEvents'] == true);
QV('d24dUseIDER', amtPowerBootCapabilities['IDER'] == true);
Expand All @@ -10952,6 +10942,7 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
QV('d24p500', amtversion > 9);
QV('d24p501', amtversion > 9);

QH('idx_d24ForceBootDevice', forceBootDeviceOptions);
setDialogMode(24, "Custom Power Action", 3, showAdvPowerDlgOk);
showAdvPowerDlgChange();
}
Expand Down Expand Up @@ -11224,17 +11215,22 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
r['PlatformErase'] = false;
}
}
if (r['ConfigurationDataReset'] != null) {
r['ConfigurationDataReset'] = false;
}
if (r['ConfigurationDataReset'] != null) { r['ConfigurationDataReset'] = false; }
rsepass = null;
// ###BEGIN###{PowerControl-Advanced}
}

// ###BEGIN###{PowerControl-OneClick}
// Add OCR TLV parameters if firmware supports OCR and Force HTTPS Boot is requested
if ((action == 999) && (Q('idx_d24ForceBootDevice').value == 7)) { // Force UEFI HTTPS Boot using URL
r['UefiBootParametersArray'] = btoa(makeUefiBootParam(1, Q('idx_d24ocrBootUrl').value.trim()) + makeUefiBootParam(20, 1, 1) + makeUefiBootParam(30, 0, 2));
const bootUrl = new URL(Q('idx_d24ocrBootUrl').value.trim());
const bootUrlUsername = bootUrl.username;
const bootUrlPassword = bootUrl.password;
bootUrl.username = bootUrl.password = '';
var uefiParams = makeUefiBootParam(1, bootUrl.href) + makeUefiBootParam(20, 1, 1) + makeUefiBootParam(30, 0, 2);
if (bootUrlUsername != '') { uefiParams += makeUefiBootParam(40, bootUrlUsername); } // HTTP basic auth username
if (bootUrlPassword != '') { uefiParams += makeUefiBootParam(41, bootUrlPassword); } // HTTP basic auth password
r['UefiBootParametersArray'] = btoa(uefiParams);
r['UefiBootNumberOfParams'] = 3;
r['BootMediaIndex'] = 0; // Do not use boot media index for One Click Recovery (OCR)
} else if ((action == 600) || (action == 601) || ((action == 999) && (Q('idx_d24ForceBootDevice').value == 6))) { // Force UEFI HTTPS Boot
Expand All @@ -11256,6 +11252,7 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
console.log("Boot Action: " + action);
console.log("Setting Boot Settings: " + ObjectToString2(r));
statusbox("Power Action", "Setting boot settings...");
return;

// Set the boot order to null, this is needed for some AMT versions that don't clear this automatically.
amtstack.CIM_BootConfigSetting_ChangeBootOrder(null, function (stack, name, response, status) {
Expand Down Expand Up @@ -11291,10 +11288,7 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
if (action == 300 || action == 301) { bootSource = 'Force Diagnostic Boot'; }
if (action == 400 || action == 401) { bootSource = 'Force PXE Boot'; }
// ###BEGIN###{PowerControl-Advanced}
if (action == 600 || action == 601) {

bootSource = 'Force OCR UEFI HTTPS Boot';
}
if (action == 600 || action == 601) { bootSource = 'Force OCR UEFI HTTPS Boot'; }
}

// Resetting Force boot data in case it was changed so that it won't be used on the next power action
Expand Down

0 comments on commit 8d83c1b

Please sign in to comment.