You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WebAuthnChain.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\Authentication\Login;
  25. class WebAuthnChain {
  26. /** @var UserDisabledCheckCommand */
  27. private $userDisabledCheckCommand;
  28. /** @var LoggedInCheckCommand */
  29. private $loggedInCheckCommand;
  30. /** @var CompleteLoginCommand */
  31. private $completeLoginCommand;
  32. /** @var CreateSessionTokenCommand */
  33. private $createSessionTokenCommand;
  34. /** @var ClearLostPasswordTokensCommand */
  35. private $clearLostPasswordTokensCommand;
  36. /** @var UpdateLastPasswordConfirmCommand */
  37. private $updateLastPasswordConfirmCommand;
  38. /** @var SetUserTimezoneCommand */
  39. private $setUserTimezoneCommand;
  40. /** @var TwoFactorCommand */
  41. private $twoFactorCommand;
  42. /** @var FinishRememberedLoginCommand */
  43. private $finishRememberedLoginCommand;
  44. /** @var WebAuthnLoginCommand */
  45. private $webAuthnLoginCommand;
  46. public function __construct(UserDisabledCheckCommand $userDisabledCheckCommand,
  47. WebAuthnLoginCommand $webAuthnLoginCommand,
  48. LoggedInCheckCommand $loggedInCheckCommand,
  49. CompleteLoginCommand $completeLoginCommand,
  50. CreateSessionTokenCommand $createSessionTokenCommand,
  51. ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand,
  52. UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand,
  53. SetUserTimezoneCommand $setUserTimezoneCommand,
  54. TwoFactorCommand $twoFactorCommand,
  55. FinishRememberedLoginCommand $finishRememberedLoginCommand
  56. ) {
  57. $this->userDisabledCheckCommand = $userDisabledCheckCommand;
  58. $this->webAuthnLoginCommand = $webAuthnLoginCommand;
  59. $this->loggedInCheckCommand = $loggedInCheckCommand;
  60. $this->completeLoginCommand = $completeLoginCommand;
  61. $this->createSessionTokenCommand = $createSessionTokenCommand;
  62. $this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand;
  63. $this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand;
  64. $this->setUserTimezoneCommand = $setUserTimezoneCommand;
  65. $this->twoFactorCommand = $twoFactorCommand;
  66. $this->finishRememberedLoginCommand = $finishRememberedLoginCommand;
  67. }
  68. public function process(LoginData $loginData): LoginResult {
  69. $chain = $this->userDisabledCheckCommand;
  70. $chain
  71. ->setNext($this->webAuthnLoginCommand)
  72. ->setNext($this->loggedInCheckCommand)
  73. ->setNext($this->completeLoginCommand)
  74. ->setNext($this->createSessionTokenCommand)
  75. ->setNext($this->clearLostPasswordTokensCommand)
  76. ->setNext($this->updateLastPasswordConfirmCommand)
  77. ->setNext($this->setUserTimezoneCommand)
  78. ->setNext($this->twoFactorCommand)
  79. ->setNext($this->finishRememberedLoginCommand);
  80. return $chain->process($loginData);
  81. }
  82. }