diff --git a/plugins/system/webauthn/src/MetadataRepository.php b/plugins/system/webauthn/src/MetadataRepository.php index 2937f3311e188..ca58b149e20e8 100644 --- a/plugins/system/webauthn/src/MetadataRepository.php +++ b/plugins/system/webauthn/src/MetadataRepository.php @@ -52,14 +52,12 @@ final class MetadataRepository implements MetadataStatementRepository private $mdsMap = []; /** - * Public constructor. + * Flag if the MSD data is loaded * - * @since 4.2.0 + * @var bool + * @since __DEPLOY_VERSION__ */ - public function __construct() - { - $this->load(); - } + private $msdDataLoaded = false; /** * Find an authenticator metadata statement given an AAGUID @@ -71,6 +69,8 @@ public function __construct() */ public function findOneByAAGUID(string $aaguid): ?MetadataStatement { + $this->load(); + $idx = $this->mdsMap[$aaguid] ?? null; return $idx ? $this->mdsCache[$idx] : null; @@ -84,6 +84,8 @@ public function findOneByAAGUID(string $aaguid): ?MetadataStatement */ public function getKnownAuthenticators(): array { + $this->load(); + $mapKeys = function (MetadataStatement $meta) { return $meta->getAaguid(); }; @@ -114,9 +116,14 @@ public function getKnownAuthenticators(): array */ private function load(bool $force = false): void { - $this->mdsCache = []; - $this->mdsMap = []; - $jwtFilename = JPATH_CACHE . '/fido.jwt'; + if ($this->msdDataLoaded && !$force) { + return; + } + + $this->msdDataLoaded = true; + $this->mdsCache = []; + $this->mdsMap = []; + $jwtFilename = JPATH_CACHE . '/fido.jwt'; // If the file exists and it's over one month old do retry loading it. if (file_exists($jwtFilename) && filemtime($jwtFilename) < (time() - 2592000)) {