disable create credential on insecure connections

This commit is contained in:
2022-10-26 10:15:49 +02:00
parent 7752fcf3b0
commit 4c0781b5a0
3 changed files with 19 additions and 2 deletions

View File

@ -42,6 +42,8 @@ class d3user_webauthn extends AdminDetailsController
*/ */
public function render() public function render()
{ {
$this->addTplParam('readonly', (bool) !(oxNew(Webauthn::class)->isAvailable()));
parent::render(); parent::render();
$soxId = $this->getEditObjectId(); $soxId = $this->getEditObjectId();

View File

@ -22,6 +22,21 @@ class Webauthn
public const SESSION_CREATIONS_OPTIONS = 'd3WebAuthnCreationOptions'; public const SESSION_CREATIONS_OPTIONS = 'd3WebAuthnCreationOptions';
public const SESSION_ASSERTION_OPTIONS = 'd3WebAuthnAssertionOptions'; public const SESSION_ASSERTION_OPTIONS = 'd3WebAuthnAssertionOptions';
public function isAvailable()
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
return true;
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ||
!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on'
) {
return true;
}
Registry::getUtilsView()->addErrorToDisplay('WebAuthn is available on secure connections only.');
return false;
}
/** /**
* @return false|string * @return false|string
*/ */

View File

@ -93,12 +93,12 @@
<tr> <tr>
<td class="edittext"> <td class="edittext">
<label for="credentialname">Name des Schlüssels</label> <label for="credentialname">Name des Schlüssels</label>
<input id="credentialname" type="text" name="credenialname"> <input id="credentialname" type="text" name="credenialname" [{$readonly}]>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="edittext"> <td class="edittext">
<button type="submit">[{oxmultilang ident="D3_WEBAUTHN_ADDKEY"}]</button> <button type="submit" [{$readonly}]>[{oxmultilang ident="D3_WEBAUTHN_ADDKEY"}]</button>
</td> </td>
</tr> </tr>
[{/block}] [{/block}]