-
-
Notifications
You must be signed in to change notification settings - Fork 817
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This gives other extensions opportunity to implement various extra login guards, e.g. excessive wrong passwords/mfa attempts. standalone: Login/TOTP improve notifications using status messages standalone: minor css improvement for login standalone: shrink QR code a bit, it was mahusive standalone: remove API_Exception → CRM_Core_Exception fix style Update tests for changed wording in standalone standalone: remove huge - we want it *bigger*! style fix
- Loading branch information
1 parent
edd3144
commit a70decb
Showing
14 changed files
with
177 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
ext/standaloneusers/Civi/Standalone/Event/LoginEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Civi\Standalone\Event; | ||
|
||
use Civi\Core\Event\GenericHookEvent; | ||
|
||
/** | ||
* Class LoginEvent | ||
* | ||
* This event (civi.standalone.login) is fired various times during the | ||
* standalone login process. | ||
* | ||
* Generally, listeners may set stopReason to a valid string (see below) | ||
* to prevent login continuing. | ||
*/ | ||
class LoginEvent extends GenericHookEvent { | ||
|
||
/** | ||
* What stage are we at? | ||
* | ||
* Valid values: | ||
* | ||
* - 'pre_credentials_check' | ||
* | ||
* userID should be set if the user exists but the password | ||
* has not been checked yet. Example use: per IP/per user flood checks. | ||
* | ||
* - 'post_credentials_check' | ||
* | ||
* userID must be set; password has been checked and stopReason | ||
* should be 'wrongUserPassword' or NULL. | ||
* Example use: limit incorrect password attempts per user. | ||
* | ||
* - 'post_mfa' | ||
* | ||
* userID must be set; password was OK. stopReason should be | ||
* 'wrongMFA' (about to reject login)' or NULL (login about to happen). | ||
* Example use: identify suspicious activity? | ||
* | ||
* - 'post_login' | ||
* | ||
* userID is set; password and possibly MFA were correct. User is | ||
* successfully logged in. Setting stopReason would have no effect. | ||
* Example use: monitor logins. | ||
* | ||
* @var string | ||
*/ | ||
public $stage; | ||
|
||
/** | ||
* The user ID of the user attempting to login. | ||
* | ||
* NULL if the username provided was invalid. | ||
* | ||
* @var int | ||
*/ | ||
public $userID; | ||
|
||
/** | ||
* If set, authentication will not proceed. | ||
* | ||
* It may be set when the event is created or altered by listeners, | ||
* e.g. loginPrevented | ||
* | ||
* Valid values: | ||
* - 'wrongUserPassword' | ||
* - 'wrongMFA' | ||
* - 'loginPrevented' | ||
* | ||
* @var null|string | ||
*/ | ||
public $stopReason = NULL; | ||
|
||
/** | ||
* Class constructor. | ||
* | ||
* @param string $stage | ||
* @param int|null $userID | ||
* @param string|null $stopReason | ||
*/ | ||
public function __construct($stage, $userID, $stopReason = NULL) { | ||
$this->stage = $stage; | ||
$this->userID = $userID; | ||
$this->stopReason = $stopReason; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getHookValues() { | ||
return [$this->stage, $this->userID, $this->stopReason]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.