[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage System.Webauthn 6 * 7 * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 defined('_JEXEC') || die; 12 13 use Joomla\Application\ApplicationInterface; 14 use Joomla\Application\SessionAwareWebApplicationInterface; 15 use Joomla\CMS\Extension\PluginInterface; 16 use Joomla\CMS\Factory; 17 use Joomla\CMS\Plugin\PluginHelper; 18 use Joomla\DI\Container; 19 use Joomla\DI\ServiceProviderInterface; 20 use Joomla\Event\DispatcherInterface; 21 use Joomla\Plugin\System\Webauthn\Authentication; 22 use Joomla\Plugin\System\Webauthn\CredentialRepository; 23 use Joomla\Plugin\System\Webauthn\Extension\Webauthn; 24 use Joomla\Plugin\System\Webauthn\MetadataRepository; 25 use Webauthn\MetadataService\MetadataStatementRepository; 26 use Webauthn\PublicKeyCredentialSourceRepository; 27 28 return new class implements ServiceProviderInterface 29 { 30 /** 31 * Registers the service provider with a DI container. 32 * 33 * @param Container $container The DI container. 34 * 35 * @return void 36 * 37 * @since 4.2.0 38 */ 39 public function register(Container $container) 40 { 41 $container->set( 42 PluginInterface::class, 43 function (Container $container) { 44 $config = (array) PluginHelper::getPlugin('system', 'webauthn'); 45 $subject = $container->get(DispatcherInterface::class); 46 47 $app = Factory::getApplication(); 48 $session = $container->has('session') ? $container->get('session') : $this->getSession($app); 49 50 $db = $container->get('DatabaseDriver'); 51 $credentialsRepository = $container->has(PublicKeyCredentialSourceRepository::class) 52 ? $container->get(PublicKeyCredentialSourceRepository::class) 53 : new CredentialRepository($db); 54 55 $metadataRepository = null; 56 $params = new Joomla\Registry\Registry($config['params'] ?? '{}'); 57 58 if ($params->get('attestationSupport', 0) == 1) { 59 $metadataRepository = $container->has(MetadataStatementRepository::class) 60 ? $container->get(MetadataStatementRepository::class) 61 : new MetadataRepository(); 62 } 63 64 $authenticationHelper = $container->has(Authentication::class) 65 ? $container->get(Authentication::class) 66 : new Authentication($app, $session, $credentialsRepository, $metadataRepository); 67 68 $plugin = new Webauthn($subject, $config, $authenticationHelper); 69 $plugin->setApplication($app); 70 71 return $plugin; 72 } 73 ); 74 } 75 76 /** 77 * Get the current application session object 78 * 79 * @param ApplicationInterface $app The application we are running in 80 * 81 * @return \Joomla\Session\SessionInterface|null 82 * 83 * @since 4.2.0 84 */ 85 private function getSession(ApplicationInterface $app) 86 { 87 return $app instanceof SessionAwareWebApplicationInterface ? $app->getSession() : null; 88 } 89 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |