Skip to content

Commit

Permalink
Passwordless authentication with WebAuthn
Browse files Browse the repository at this point in the history
Working administration as well.
  • Loading branch information
Nicholas K. Dionysopoulos committed Jul 25, 2019
1 parent 74a5f62 commit 9c535f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 300 deletions.
284 changes: 0 additions & 284 deletions build/media_source/plg_system_webauthn/scss/backend.scss

This file was deleted.

32 changes: 17 additions & 15 deletions layouts/plugins/system/webauthn/manage.php
Expand Up @@ -7,15 +7,15 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

use Joomla\Plugin\System\Webauthn\Helper\CredentialsCreation;
use Joomla\Plugin\System\Webauthn\Helper\Joomla;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserHelper;
use Joomla\Plugin\System\Webauthn\Helper\CredentialsCreation;
use Joomla\Plugin\System\Webauthn\Helper\Joomla;

/**
* Passwordless Login management interface
Expand Down Expand Up @@ -62,24 +62,24 @@
* do not replace existing values. This causes any retries to fail. By using a data storage object we circumvent
* that problem.
*/
$randomId = 'akpwl_' . UserHelper::genRandomPassword(32);
$randomId = 'plg_system_webauthn_' . UserHelper::genRandomPassword(32);
$publicKey = $allow_add ? base64_encode(CredentialsCreation::createPublicKey($user)) : '{}';
$postbackURL = base64_encode(rtrim(Uri::base(), '/') . '/index.php?' . Joomla::getToken() . '=1');
?>
<div class="akpwl" id="akpwl-management-interface">
<div class="plg_system_webauthn" id="plg_system_webauthn-management-interface">
<span id="<?= $randomId ?>"
data-public_key="<?= $publicKey ?>"
data-postback_url="<?= $postbackURL ?>"
></span>

<?php if (is_string($error) && !empty($error)): ?>
<div class="akpwn-block--error">
<div class="alert alert-danger">
<?= htmlentities($error) ?>
</div>
<?php endif; ?>

<table class="akpwl-table--striped">
<thead>
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th><?= Text::_('PLG_SYSTEM_WEBAUTHN_MANAGE_FIELD_KEYLABEL_LABEL') ?></th>
<th><?= Text::_('PLG_SYSTEM_WEBAUTHN_MANAGE_HEADER_ACTIONS_LABEL') ?></th>
Expand All @@ -91,12 +91,12 @@
<td><?= htmlentities($method['label']) ?></td>
<td>
<button onclick="return plg_system_webauthn_edit_label(this, '<?= $randomId ?>');"
class="akpwl-btn--teal">
class="btn btn-secondary">
<span class="icon-edit icon-white"></span>
<?= Text::_('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_EDIT_LABEL') ?>
</button>
<button onclick="return plg_system_webauthn_delete(this, '<?= $randomId ?>');"
class="akpwl-btn--red">
class="btn btn-danger">
<span class="icon-minus-sign icon-white"></span>
<?= Text::_('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_DELETE_LABEL') ?>
</button>
Expand All @@ -114,12 +114,14 @@ class="akpwl-btn--red">
</table>

<?php if ($allow_add): ?>
<p class="akpwl-manage-add-container">
<a onclick="plg_system_webauthn_create_credentials('<?= $randomId ?>', '#akpwl-management-interface');"
class="akpwl-btn--green--block">
<span class="icon-plus icon-white"></span>
<p class="plg_system_webauthn-manage-add-container">
<button
type="button"
onclick="plg_system_webauthn_create_credentials('<?= $randomId ?>', '#plg_system_webauthn-management-interface'); return false;"
class="btn btn-success btn-block">
<span class="icon-plus icon-white"></span>
<?= Text::_('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_ADD_LABEL') ?>
</a>
</p>
</button>
</p>
<?php endif; ?>
</div>
2 changes: 1 addition & 1 deletion plugins/system/webauthn/fields/webauthn.php
Expand Up @@ -45,7 +45,7 @@ function getInput()
return Text::_('PLG_SYSTEM_WEBAUTHN_ERR_NOUSER');
}

HTMLHelper::_('script', 'plg_system_webauthn/dist/management.js', [
HTMLHelper::_('script', 'plg_system_webauthn/management.js', [
'relative' => true,
'framework' => true,
]);
Expand Down

0 comments on commit 9c535f3

Please sign in to comment.