File manager - Edit - /home/opticamezl/www/newok/Authentication.zip
Back
PK �D�\���� � Password/Argon2idHandler.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; use Joomla\Authentication\Password\Argon2idHandler as BaseArgon2idHandler; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Password handler for Argon2id hashed passwords * * @since 4.0.0 */ class Argon2idHandler extends BaseArgon2idHandler implements CheckIfRehashNeededHandlerInterface { /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool { return password_needs_rehash($hash, PASSWORD_ARGON2ID); } } PK �D�\��r Password/PHPassHandler.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; use Joomla\Authentication\Password\HandlerInterface; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Password handler for PHPass hashed passwords * * @since 4.0.0 * * @deprecated 4.0 will be removed in 6.0 * Support for PHPass hashed passwords will be removed without replacement */ class PHPassHandler implements HandlerInterface, CheckIfRehashNeededHandlerInterface { /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool { return true; } /** * Generate a hash for a plaintext password * * @param string $plaintext The plaintext password to validate * @param array $options Options for the hashing operation * * @return string * * @since 4.0.0 */ public function hashPassword($plaintext, array $options = []) { return $this->getPasswordHash()->HashPassword($plaintext); } /** * Check that the password handler is supported in this environment * * @return boolean * * @since 4.0.0 */ public static function isSupported() { return class_exists(\PasswordHash::class); } /** * Validate a password * * @param string $plaintext The plain text password to validate * @param string $hashed The password hash to validate against * * @return boolean * * @since 4.0.0 */ public function validatePassword($plaintext, $hashed) { return $this->getPasswordHash()->CheckPassword($plaintext, $hashed); } /** * Get an instance of the PasswordHash class * * @return \PasswordHash * * @since 4.0.0 */ private function getPasswordHash(): \PasswordHash { return new \PasswordHash(10, true); } } PK �D�\EzP�� � Password/MD5Handler.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; use Joomla\Authentication\Password\HandlerInterface; use Joomla\CMS\Crypt\Crypt; use Joomla\CMS\User\UserHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Password handler for MD5 hashed passwords * * @since 4.0.0 * * @deprecated 4.0 will be removed in 6.0 * Support for MD5 hashed passwords will be removed without replacement */ class MD5Handler implements HandlerInterface, CheckIfRehashNeededHandlerInterface { /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool { return true; } /** * Generate a hash for a plaintext password * * @param string $plaintext The plaintext password to validate * @param array $options Options for the hashing operation * * @return string * * @since 4.0.0 */ public function hashPassword($plaintext, array $options = []) { $salt = UserHelper::genRandomPassword(32); $crypted = md5($plaintext . $salt); return $crypted . ':' . $salt; } /** * Check that the password handler is supported in this environment * * @return boolean * * @since 4.0.0 */ public static function isSupported() { return true; } /** * Validate a password * * @param string $plaintext The plain text password to validate * @param string $hashed The password hash to validate against * * @return boolean * * @since 4.0.0 */ public function validatePassword($plaintext, $hashed) { // Check the password $parts = explode(':', $hashed); $salt = @$parts[1]; // Compile the hash to compare // If the salt is empty AND there is a ':' in the original hash, we must append ':' at the end $testcrypt = md5($plaintext . $salt) . ($salt ? ':' . $salt : (strpos($hashed, ':') !== false ? ':' : '')); return Crypt::timingSafeCompare($hashed, $testcrypt); } } PK �D�\<�٢� � Password/Argon2iHandler.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; use Joomla\Authentication\Password\Argon2iHandler as BaseArgon2iHandler; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Password handler for Argon2i hashed passwords * * @since 4.0.0 */ class Argon2iHandler extends BaseArgon2iHandler implements CheckIfRehashNeededHandlerInterface { /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool { return password_needs_rehash($hash, PASSWORD_ARGON2I); } } PK �D�\��1� Password/ChainedHandler.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; use Joomla\Authentication\Password\HandlerInterface; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Password handler supporting testing against a chain of handlers * * @since 4.0.0 */ class ChainedHandler implements HandlerInterface, CheckIfRehashNeededHandlerInterface { /** * The password handlers in use by this chain. * * @var HandlerInterface[] * @since 4.0.0 */ private $handlers = []; /** * Add a handler to the chain * * @param HandlerInterface $handler The password handler to add * * @return void * * @since 4.0.0 */ public function addHandler(HandlerInterface $handler) { $this->handlers[] = $handler; } /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool { foreach ($this->handlers as $handler) { if ($handler instanceof CheckIfRehashNeededHandlerInterface && $handler->isSupported() && $handler->checkIfRehashNeeded($hash)) { return true; } } return false; } /** * Generate a hash for a plaintext password * * @param string $plaintext The plaintext password to validate * @param array $options Options for the hashing operation * * @return void * * @since 4.0.0 * @throws \RuntimeException */ public function hashPassword($plaintext, array $options = []) { throw new \RuntimeException('The chained password handler cannot be used to hash a password'); } /** * Check that the password handler is supported in this environment * * @return boolean * * @since 4.0.0 */ public static function isSupported() { return true; } /** * Validate a password * * @param string $plaintext The plain text password to validate * @param string $hashed The password hash to validate against * * @return boolean * * @since 4.0.0 */ public function validatePassword($plaintext, $hashed) { foreach ($this->handlers as $handler) { if ($handler->isSupported() && $handler->validatePassword($plaintext, $hashed)) { return true; } } return false; } } PK �D�\�[!� � Password/BCryptHandler.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; use Joomla\Authentication\Password\BCryptHandler as BaseBCryptHandler; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Password handler for BCrypt hashed passwords * * @since 4.0.0 */ class BCryptHandler extends BaseBCryptHandler implements CheckIfRehashNeededHandlerInterface { /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool { return password_needs_rehash($hash, PASSWORD_BCRYPT); } } PK �D�\0��k 0 Password/CheckIfRehashNeededHandlerInterface.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication\Password; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface for a password handler which supports checking if the password requires rehashing * * @since 4.0.0 */ interface CheckIfRehashNeededHandlerInterface { /** * Check if the password requires rehashing * * @param string $hash The password hash to check * * @return boolean * * @since 4.0.0 */ public function checkIfRehashNeeded(string $hash): bool; } PK �D�\�Xb�� � . ProviderAwareAuthenticationPluginInterface.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright Copyright (C) 2022 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface class defining the necessary methods for an authentication plugin to be provider aware * Please note: might be deprecated with Joomla 4.2 * * @since 3.10.7 */ interface ProviderAwareAuthenticationPluginInterface { /** * Return if plugin acts as primary provider * * @return true * * @since 3.10.7 */ public static function isPrimaryProvider(); /** * Return provider name * * @return string * * @since 3.10.7 */ public static function getProviderName(); } PK �D�\ 11� � Authentication.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Event\DispatcherAwareTrait; use Joomla\Event\DispatcherInterface; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Authentication class, provides an interface for the Joomla authentication system * * @since 1.7.0 */ class Authentication { use DispatcherAwareTrait; /** * This is the status code returned when the authentication is success (permit login) * * @var integer * @since 1.7.0 */ public const STATUS_SUCCESS = 1; /** * Status to indicate cancellation of authentication (unused) * * @var integer * @since 1.7.0 */ public const STATUS_CANCEL = 2; /** * This is the status code returned when the authentication failed (prevent login if no success) * * @var integer * @since 1.7.0 */ public const STATUS_FAILURE = 4; /** * This is the status code returned when the account has expired (prevent login) * * @var integer * @since 1.7.0 */ public const STATUS_EXPIRED = 8; /** * This is the status code returned when the account has been denied (prevent login) * * @var integer * @since 1.7.0 */ public const STATUS_DENIED = 16; /** * This is the status code returned when the account doesn't exist (not an error) * * @var integer * @since 1.7.0 */ public const STATUS_UNKNOWN = 32; /** * @var Authentication[] JAuthentication instances container. * @since 1.7.3 */ protected static $instance = []; /** * Plugin Type to run * * @var string * @since 4.0.0 */ protected $pluginType; /** * Constructor * * @param string $pluginType The plugin type to run authorisation and authentication on * @param DispatcherInterface $dispatcher The event dispatcher we're going to use * * @since 1.7.0 */ public function __construct(string $pluginType = 'authentication', DispatcherInterface $dispatcher = null) { // Set the dispatcher if (!\is_object($dispatcher)) { $dispatcher = Factory::getContainer()->get('dispatcher'); } $this->setDispatcher($dispatcher); $this->pluginType = $pluginType; $isLoaded = PluginHelper::importPlugin($this->pluginType); if (!$isLoaded) { Log::add(Text::_('JLIB_USER_ERROR_AUTHENTICATION_LIBRARIES'), Log::WARNING, 'jerror'); } } /** * Returns the global authentication object, only creating it * if it doesn't already exist. * * @param string $pluginType The plugin type to run authorisation and authentication on * * @return Authentication The global Authentication object * * @since 1.7.0 */ public static function getInstance(string $pluginType = 'authentication') { if (empty(self::$instance[$pluginType])) { self::$instance[$pluginType] = new static($pluginType); } return self::$instance[$pluginType]; } /** * Finds out if a set of login credentials are valid by asking all observing * objects to run their respective authentication routines. * * @param array $credentials Array holding the user credentials. * @param array $options Array holding user options. * * @return AuthenticationResponse Response object with status variable filled in for last plugin or first successful plugin. * * @see AuthenticationResponse * @since 1.7.0 */ public function authenticate($credentials, $options = []) { // Get plugins $plugins = PluginHelper::getPlugin($this->pluginType); // Create authentication response $response = new AuthenticationResponse(); /* * Loop through the plugins and check if the credentials can be used to authenticate * the user * * Any errors raised in the plugin should be returned via the AuthenticationResponse * and handled appropriately. */ foreach ($plugins as $plugin) { $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); if (!method_exists($plugin, 'onUserAuthenticate')) { // Bail here if the plugin can't be created Log::add(Text::sprintf('JLIB_USER_ERROR_AUTHENTICATION_FAILED_LOAD_PLUGIN', $plugin->name), Log::WARNING, 'jerror'); continue; } // Try to authenticate $plugin->onUserAuthenticate($credentials, $options, $response); // If authentication is successful break out of the loop if ($response->status === self::STATUS_SUCCESS) { if (empty($response->type)) { $response->type = $plugin->_name ?? $plugin->name; } break; } } if (empty($response->username)) { $response->username = $credentials['username']; } if (empty($response->fullname)) { $response->fullname = $credentials['username']; } if (empty($response->password) && isset($credentials['password'])) { $response->password = $credentials['password']; } return $response; } /** * Authorises that a particular user should be able to login * * @param AuthenticationResponse $response response including username of the user to authorise * @param array $options list of options * * @return AuthenticationResponse[] Array of authentication response objects * * @since 1.7.0 * @throws \Exception */ public function authorise($response, $options = []) { // Get plugins in case they haven't been imported already PluginHelper::importPlugin('user'); $results = Factory::getApplication()->triggerEvent('onUserAuthorisation', [$response, $options]); return $results; } } PK �D�\�p�j� � AuthenticationResponse.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Authentication; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Authentication response class, provides an object for storing user and error details * * @since 1.7.0 */ class AuthenticationResponse { /** * Response status (see status codes) * * @var string * @since 1.7.0 */ public $status = Authentication::STATUS_FAILURE; /** * The type of authentication that was successful * * @var string * @since 1.7.0 */ public $type = ''; /** * The error message * * @var string * @since 1.7.0 */ public $error_message = ''; /** * Any UTF-8 string that the End User wants to use as a username. * * @var string * @since 1.7.0 */ public $username = ''; /** * Any UTF-8 string that the End User wants to use as a password. * * @var string * @since 1.7.0 */ public $password = ''; /** * The email address of the End User as specified in section 3.4.1 of [RFC2822] * * @var string * @since 1.7.0 */ public $email = ''; /** * UTF-8 string free text representation of the End User's full name. * * @var string * @since 1.7.0 */ public $fullname = ''; /** * The End User's date of birth as YYYY-MM-DD. Any values whose representation uses * fewer than the specified number of digits should be zero-padded. The length of this * value MUST always be 10. If the End User user does not want to reveal any particular * component of this value, it MUST be set to zero. * * For instance, if an End User wants to specify that their date of birth is in 1980, but * not the month or day, the value returned SHALL be "1980-00-00". * * @var string * @since 1.7.0 */ public $birthdate = ''; /** * The End User's gender, "M" for male, "F" for female. * * @var string * @since 1.7.0 */ public $gender = ''; /** * UTF-8 string free text that SHOULD conform to the End User's country's postal system. * * @var string * @since 1.7.0 */ public $postcode = ''; /** * The End User's country of residence as specified by ISO3166. * * @var string * @since 1.7.0 */ public $country = ''; /** * End User's preferred language as specified by ISO639. * * @var string * @since 1.7.0 */ public $language = ''; /** * ASCII string from TimeZone database * * @var string * @since 1.7.0 */ public $timezone = ''; } PK �D�\���� � Password/Argon2idHandler.phpnu �[��� PK �D�\��r Password/PHPassHandler.phpnu �[��� PK �D�\EzP�� � d Password/MD5Handler.phpnu �[��� PK �D�\<�٢� � � Password/Argon2iHandler.phpnu �[��� PK �D�\��1� � Password/ChainedHandler.phpnu �[��� PK �D�\�[!� � �&