[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/authentication/src/Strategies/ -> LocalStrategy.php (source)

   1  <?php
   2  /**
   3   * Part of the Joomla Framework Authentication Package
   4   *
   5   * @copyright  Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
   6   * @license    GNU General Public License version 2 or later; see LICENSE
   7   */
   8  
   9  namespace Joomla\Authentication\Strategies;
  10  
  11  use Joomla\Authentication\AbstractUsernamePasswordAuthenticationStrategy;
  12  use Joomla\Authentication\Authentication;
  13  use Joomla\Authentication\Password\HandlerInterface;
  14  use Joomla\Input\Input;
  15  
  16  /**
  17   * Joomla Framework Local Strategy Authentication class
  18   *
  19   * @since  1.0
  20   */
  21  class LocalStrategy extends AbstractUsernamePasswordAuthenticationStrategy
  22  {
  23      /**
  24       * The credential store.
  25       *
  26       * @var    array
  27       * @since  1.0
  28       */
  29      private $credentialStore;
  30  
  31      /**
  32       * The Input object
  33       *
  34       * @var    Input
  35       * @since  1.0
  36       */
  37      private $input;
  38  
  39      /**
  40       * Strategy Constructor
  41       *
  42       * @param   Input             $input            The input object from which to retrieve the request credentials.
  43       * @param   array             $credentialStore  Hash of username and hash pairs.
  44       * @param   HandlerInterface  $passwordHandler  The password handler.
  45       *
  46       * @since   1.0
  47       */
  48  	public function __construct(Input $input, array $credentialStore = [], ?HandlerInterface $passwordHandler = null)
  49      {
  50          parent::__construct($passwordHandler);
  51  
  52          $this->credentialStore = $credentialStore;
  53          $this->input           = $input;
  54      }
  55  
  56      /**
  57       * Attempt to authenticate the username and password pair.
  58       *
  59       * @return  string|boolean  A string containing a username if authentication is successful, false otherwise.
  60       *
  61       * @since   1.0
  62       */
  63  	public function authenticate()
  64      {
  65          $username = $this->input->get('username', false, 'username');
  66          $password = $this->input->get('password', false, 'raw');
  67  
  68          if (!$username || !$password)
  69          {
  70              $this->status = Authentication::NO_CREDENTIALS;
  71  
  72              return false;
  73          }
  74  
  75          return $this->doAuthenticate($username, $password);
  76      }
  77  
  78      /**
  79       * Retrieve the hashed password for the specified user.
  80       *
  81       * @param   string  $username  Username to lookup.
  82       *
  83       * @return  string|boolean  Hashed password on success or boolean false on failure.
  84       *
  85       * @since   1.1.0
  86       */
  87  	protected function getHashedPassword($username)
  88      {
  89          return $this->credentialStore[$username] ?? false;
  90      }
  91  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer