[ 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) 2020 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Plugin\System\Webauthn\Extension; 12 13 use Joomla\CMS\Application\CMSApplication; 14 use Joomla\CMS\Application\CMSApplicationInterface; 15 use Joomla\CMS\Event\CoreEventAware; 16 use Joomla\CMS\Factory; 17 use Joomla\CMS\Log\Log; 18 use Joomla\CMS\Plugin\CMSPlugin; 19 use Joomla\Database\DatabaseAwareInterface; 20 use Joomla\Database\DatabaseAwareTrait; 21 use Joomla\Database\DatabaseDriver; 22 use Joomla\Event\DispatcherInterface; 23 use Joomla\Event\SubscriberInterface; 24 use Joomla\Plugin\System\Webauthn\Authentication; 25 use Joomla\Plugin\System\Webauthn\PluginTraits\AdditionalLoginButtons; 26 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandler; 27 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandlerChallenge; 28 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandlerCreate; 29 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandlerDelete; 30 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandlerInitCreate; 31 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandlerLogin; 32 use Joomla\Plugin\System\Webauthn\PluginTraits\AjaxHandlerSaveLabel; 33 use Joomla\Plugin\System\Webauthn\PluginTraits\EventReturnAware; 34 use Joomla\Plugin\System\Webauthn\PluginTraits\UserDeletion; 35 use Joomla\Plugin\System\Webauthn\PluginTraits\UserProfileFields; 36 37 // phpcs:disable PSR1.Files.SideEffects 38 \defined('_JEXEC') or die; 39 // phpcs:enable PSR1.Files.SideEffects 40 41 /** 42 * WebAuthn Passwordless Login plugin 43 * 44 * The plugin features are broken down into Traits for the sole purpose of making an otherwise 45 * supermassive class somewhat manageable. You can find the Traits inside the Webauthn/PluginTraits 46 * folder. 47 * 48 * @since 4.0.0 49 */ 50 final class Webauthn extends CMSPlugin implements SubscriberInterface 51 { 52 // Add WebAuthn buttons 53 use AdditionalLoginButtons; 54 55 // AJAX request handlers 56 use AjaxHandler; 57 use AjaxHandlerInitCreate; 58 use AjaxHandlerCreate; 59 use AjaxHandlerSaveLabel; 60 use AjaxHandlerDelete; 61 use AjaxHandlerChallenge; 62 use AjaxHandlerLogin; 63 64 // Utility methods for setting the events' return values 65 use EventReturnAware; 66 use CoreEventAware; 67 68 // Custom user profile fields 69 use UserProfileFields; 70 71 // Handle user profile deletion 72 use UserDeletion; 73 74 /** 75 * Autoload the language files 76 * 77 * @var boolean 78 * @since 4.2.0 79 */ 80 protected $autoloadLanguage = true; 81 82 /** 83 * Should I try to detect and register legacy event listeners? 84 * 85 * @var boolean 86 * @since 4.2.0 87 * 88 * @deprecated 89 */ 90 protected $allowLegacyListeners = false; 91 92 /** 93 * The WebAuthn authentication helper object 94 * 95 * @var Authentication 96 * @since 4.2.0 97 */ 98 protected $authenticationHelper; 99 100 /** 101 * Constructor. Loads the language files as well. 102 * 103 * @param DispatcherInterface $subject The object to observe 104 * @param array $config An optional associative array of configuration 105 * settings. Recognized key values include 'name', 106 * 'group', 'params', 'language (this list is not meant 107 * to be comprehensive). 108 * @param Authentication|null $authHelper The WebAuthn helper object 109 * 110 * @since 4.0.0 111 */ 112 public function __construct(&$subject, array $config = [], Authentication $authHelper = null) 113 { 114 parent::__construct($subject, $config); 115 116 /** 117 * Note: Do NOT try to load the language in the constructor. This is called before Joomla initializes the 118 * application language. Therefore the temporary Joomla language object and all loaded strings in it will be 119 * destroyed on application initialization. As a result we need to call loadLanguage() in each method 120 * individually, even though all methods make use of language strings. 121 */ 122 123 // Register a debug log file writer 124 $logLevels = Log::ERROR | Log::CRITICAL | Log::ALERT | Log::EMERGENCY; 125 126 if (\defined('JDEBUG') && JDEBUG) { 127 $logLevels = Log::ALL; 128 } 129 130 Log::addLogger([ 131 'text_file' => "webauthn_system.php", 132 'text_entry_format' => '{DATETIME} {PRIORITY} {CLIENTIP} {MESSAGE}', 133 ], $logLevels, ["webauthn.system"]); 134 135 $this->authenticationHelper = $authHelper ?? (new Authentication()); 136 $this->authenticationHelper->setAttestationSupport($this->params->get('attestationSupport', 0) == 1); 137 } 138 139 /** 140 * Returns the Authentication helper object 141 * 142 * @return Authentication 143 * 144 * @since 4.2.0 145 */ 146 public function getAuthenticationHelper(): Authentication 147 { 148 return $this->authenticationHelper; 149 } 150 151 /** 152 * Returns an array of events this subscriber will listen to. 153 * 154 * @return array 155 * 156 * @since 4.2.0 157 */ 158 public static function getSubscribedEvents(): array 159 { 160 try { 161 $app = Factory::getApplication(); 162 } catch (\Exception $e) { 163 return []; 164 } 165 166 if (!$app->isClient('site') && !$app->isClient('administrator')) { 167 return []; 168 } 169 170 return [ 171 'onAjaxWebauthn' => 'onAjaxWebauthn', 172 'onAjaxWebauthnChallenge' => 'onAjaxWebauthnChallenge', 173 'onAjaxWebauthnCreate' => 'onAjaxWebauthnCreate', 174 'onAjaxWebauthnDelete' => 'onAjaxWebauthnDelete', 175 'onAjaxWebauthnInitcreate' => 'onAjaxWebauthnInitcreate', 176 'onAjaxWebauthnLogin' => 'onAjaxWebauthnLogin', 177 'onAjaxWebauthnSavelabel' => 'onAjaxWebauthnSavelabel', 178 'onUserAfterDelete' => 'onUserAfterDelete', 179 'onUserLoginButtons' => 'onUserLoginButtons', 180 'onContentPrepareForm' => 'onContentPrepareForm', 181 'onContentPrepareData' => 'onContentPrepareData', 182 ]; 183 } 184 }
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 |