- md5
- 19ea07b4ca38d893ea4365199130f272
- sha1
- 57ce2d3ea1fb41103412d7f98104e679af9361c4
- sha256
- c737e846aa56a74d831fc98a47a6dcc9de351148453007a99357b214a3dab8fc
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Webauthn
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') || die;
use Joomla\Application\ApplicationInterface;
use Joomla\Application\SessionAwareWebApplicationInterface;
use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Plugin\System\Webauthn\Authentication;
use Joomla\Plugin\System\Webauthn\CredentialRepository;
use Joomla\Plugin\System\Webauthn\Extension\Webauthn;
use Joomla\Plugin\System\Webauthn\MetadataRepository;
use Joomla\Registry\Registry;
use Webauthn\MetadataService\MetadataStatementRepository;
use Webauthn\PublicKeyCredentialSourceRepository;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.2.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$app = Factory::getApplication();
$session = $container->has('session') ? $container->get('session') : $this->getSession($app);
$db = $container->get(DatabaseInterface::class);
$credentialsRepository = $container->has(PublicKeyCredentialSourceRepository::class)
? $container->get(PublicKeyCredentialSourceRepository::class)
: new CredentialRepository($db);
$metadataRepository = null;
$params = new Registry($config['params'] ?? '{}');
if ($params->get('attestationSupport', 0) == 1) {
$metadataRepository = $container->has(MetadataStatementRepository::class)
? $container->get(MetadataStatementRepository::class)
: new MetadataRepository();
}
$authenticationHelper = $container->has(Authentication::class)
? $container->get(Authentication::class)
: new Authentication($app, $session, $credentialsRepository, $metadataRepository);
$plugin = new Webauthn(
(array) PluginHelper::getPlugin('system', 'webauthn'),
$authenticationHelper
);
$plugin->setApplication($app);
return $plugin;
}
);
}
/**
* Get the current application session object
*
* @param ApplicationInterface $app The application we are running in
*
* @return \Joomla\Session\SessionInterface|null
*
* @since 4.2.0
*/
private function getSession(ApplicationInterface $app)
{
return $app instanceof SessionAwareWebApplicationInterface ? $app->getSession() : null;
}
};
The same content is in 43 releases, Joomla 5.4.0-beta2 to 6.1.0-alpha3. See them all, or every version of this file.