From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- .../libraries/classes/Plugins/TwoFactorPlugin.php | 183 +++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 srcs/phpmyadmin/libraries/classes/Plugins/TwoFactorPlugin.php (limited to 'srcs/phpmyadmin/libraries/classes/Plugins/TwoFactorPlugin.php') diff --git a/srcs/phpmyadmin/libraries/classes/Plugins/TwoFactorPlugin.php b/srcs/phpmyadmin/libraries/classes/Plugins/TwoFactorPlugin.php new file mode 100644 index 0000000..23534a1 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Plugins/TwoFactorPlugin.php @@ -0,0 +1,183 @@ +_twofactor = $twofactor; + $this->_provided = false; + $this->_message = ''; + $this->template = new Template(); + } + + /** + * Returns authentication error message + * + * @return string + */ + public function getError() + { + if ($this->_provided) { + if (! empty($this->_message)) { + return Message::rawError( + sprintf(__('Two-factor authentication failed: %s'), $this->_message) + )->getDisplay(); + } + return Message::rawError( + __('Two-factor authentication failed.') + )->getDisplay(); + } + return ''; + } + + /** + * Checks authentication, returns true on success + * + * @return boolean + */ + public function check() + { + return true; + } + + /** + * Renders user interface to enter two-factor authentication + * + * @return string HTML code + */ + public function render() + { + return ''; + } + + /** + * Renders user interface to configure two-factor authentication + * + * @return string HTML code + */ + public function setup() + { + return ''; + } + + /** + * Performs backend configuration + * + * @return boolean + */ + public function configure() + { + return true; + } + + /** + * Get user visible name + * + * @return string + */ + public static function getName() + { + return __('No Two-Factor Authentication'); + } + + /** + * Get user visible description + * + * @return string + */ + public static function getDescription() + { + return __('Login using password only.'); + } + + /** + * Return an applicaiton ID + * + * Either hostname or hostname with scheme. + * + * @param boolean $return_url Whether to generate URL + * + * @return string + */ + public function getAppId($return_url) + { + /** @var Config $PMA_Config */ + global $PMA_Config; + + $url = $PMA_Config->get('PmaAbsoluteUri'); + $parsed = []; + if (! empty($url)) { + $parsed = parse_url($url); + } + if (empty($parsed['scheme'])) { + $parsed['scheme'] = $PMA_Config->isHttps() ? 'https' : 'http'; + } + if (empty($parsed['host'])) { + $parsed['host'] = Core::getenv('HTTP_HOST'); + } + if ($return_url) { + return $parsed['scheme'] . '://' . $parsed['host'] . (! empty($parsed['port']) ? ':' . $parsed['port'] : ''); + } else { + return $parsed['host']; + } + } +} -- cgit