credential_id = $credential_id; $this->accounts = $accounts; $this->password_hash = $password_hash; } function credentials() { $password = $this->verifiedPassword(Adminer\get_password()); if ($password !== null) { // the server doesn't know the password derived from the passkey so send only the stored password, empty for servers not requiring it return array(Adminer\SERVER, $_GET["username"], $password); } } function login($login, $password) { if ($this->verifiedPassword($password) !== null) { return true; // the passkey has verified the user } if ($this->password_hash != "") { return $this->lang('Log in with the passkey.'); } } /** Get the stored password from the password verified by the passkey * @param string|false|null $password the password derived from the passkey, a colon and the stored password * @return string|null null if the passkey has not verified the password */ protected function verifiedPassword($password) { if ($this->password_hash != "" && is_string($password) && preg_match('~^([0-9a-f]{64}):~', $password, $match) && hash('sha256', $match[1]) === $this->password_hash) { return substr($password, strlen($match[0])); } } function loginFormField($name, $heading, $value) { if ($name == 'db') { // the last field, the row is printed right above the submit button ob_start(); $this->printRow(); return $heading . $value . "\n" . ob_get_clean(); } } /** Print the login form row with the passkey buttons; the buttons are displayed only if the passkey can be used, otherwise the requirements are */ protected function printRow() { // 1 - JSON_HEX_TAG because the values are printed to a script element, 256 - JSON_UNESCAPED_UNICODE $lang = json_encode(array( 'unsupported' => $this->lang('The passkey does not support storing passwords.'), 'invalid' => $this->lang('The accounts cannot be decrypted by this passkey.'), 'browser' => $this->lang('This browser does not support passkeys.'), ), 1 | 256); ?>
lang('Fill in the login form and add it to the passkey.'); ?> '> '>
lang('Add this line to %s:', 'adminer-plugins.php') . "\n"; ?>