diff --git a/src/server/cyberhex-code/test/user.html b/src/server/cyberhex-code/test/user.html index 82d9e35..4087f47 100644 --- a/src/server/cyberhex-code/test/user.html +++ b/src/server/cyberhex-code/test/user.html @@ -1,106 +1,355 @@ - - - lbuchs/WebAuthn Test - - - -

lbuchs/WebAuthn

-
- - -
+ + lbuchs/WebAuthn Test + + - - + + /** + * Get URL parameter + * @returns {String} + */ + function getGetParams() { + let url = ''; + + url += '&apple=' + (document.getElementById('cert_apple').checked ? '1' : '0'); + url += '&yubico=' + (document.getElementById('cert_yubico').checked ? '1' : '0'); + url += '&solo=' + (document.getElementById('cert_solo').checked ? '1' : '0'); + url += '&hypersecu=' + (document.getElementById('cert_hypersecu').checked ? '1' : '0'); + url += '&google=' + (document.getElementById('cert_google').checked ? '1' : '0'); + url += 'µsoft=' + (document.getElementById('cert_microsoft').checked ? '1' : '0'); + url += '&mds=' + (document.getElementById('cert_mds').checked ? '1' : '0'); + + url += '&requireResidentKey=' + (document.getElementById('requireResidentKey').checked ? '1' : '0'); + + url += '&type_usb=' + (document.getElementById('type_usb').checked ? '1' : '0'); + url += '&type_nfc=' + (document.getElementById('type_nfc').checked ? '1' : '0'); + url += '&type_ble=' + (document.getElementById('type_ble').checked ? '1' : '0'); + url += '&type_int=' + (document.getElementById('type_int').checked ? '1' : '0'); + url += '&type_hybrid=' + (document.getElementById('type_hybrid').checked ? '1' : '0'); + + url += '&fmt_android-key=' + (document.getElementById('fmt_android-key').checked ? '1' : '0'); + url += '&fmt_android-safetynet=' + (document.getElementById('fmt_android-safetynet').checked ? '1' : '0'); + url += '&fmt_apple=' + (document.getElementById('fmt_apple').checked ? '1' : '0'); + url += '&fmt_fido-u2f=' + (document.getElementById('fmt_fido-u2f').checked ? '1' : '0'); + url += '&fmt_none=' + (document.getElementById('fmt_none').checked ? '1' : '0'); + url += '&fmt_packed=' + (document.getElementById('fmt_packed').checked ? '1' : '0'); + url += '&fmt_tpm=' + (document.getElementById('fmt_tpm').checked ? '1' : '0'); + + url += '&rpId=' + encodeURIComponent(document.getElementById('rpId').value); + + url += '&userId=' + encodeURIComponent(document.getElementById('userId').value); + url += '&userName=' + encodeURIComponent(document.getElementById('userName').value); + url += '&userDisplayName=' + encodeURIComponent(document.getElementById('userDisplayName').value); + + if (document.getElementById('userVerification_required').checked) { + url += '&userVerification=required'; + + } else if (document.getElementById('userVerification_preferred').checked) { + url += '&userVerification=preferred'; + + } else if (document.getElementById('userVerification_discouraged').checked) { + url += '&userVerification=discouraged'; + } + + return url; + } + + function reloadServerPreview() { + let iframe = document.getElementById('serverPreview'); + iframe.src = iframe.src; + } + + function setAttestation(attestation) { + let inputEls = document.getElementsByTagName('input'); + for (const inputEl of inputEls) { + if (inputEl.id && inputEl.id.match(/^(fmt|cert)\_/)) { + inputEl.disabled = !attestation; + } + if (inputEl.id && inputEl.id.match(/^fmt\_/)) { + inputEl.checked = attestation ? inputEl.id !== 'fmt_none' : inputEl.id === 'fmt_none'; + } + if (inputEl.id && inputEl.id.match(/^cert\_/)) { + inputEl.checked = attestation ? inputEl.id === 'cert_mds' : false; + } + } + } + + /** + * force https on load + * @returns {undefined} + */ + window.onload = function() { + if (location.protocol !== 'https:' && location.host !== 'localhost') { + location.href = location.href.replace('http', 'https'); + } + if (!document.getElementById('rpId').value) { + document.getElementById('rpId').value = location.hostname; + } + + if (!document.getElementById('attestation_yes').checked) { + setAttestation(false); + } + } + + + + + +

lbuchs/WebAuthn

+
A simple PHP WebAuthn (FIDO2) server library.
+
+
+
 
+
 
+
Simple working demo for the lbuchs/WebAuthn library.
+
+
 
+ + + + + + + +
+ + + + + +
+
+

Here you can see what's saved on the server:

+ +
+
+ + \ No newline at end of file