nojimage / cakephp-login-attempts
LoginAttempts plugin for CakePHP
Package info
github.com/nojimage/cakephp-login-attempts
Type:cakephp-plugin
pkg:composer/nojimage/cakephp-login-attempts
Requires
- php: ^8.1
- cakephp/authentication: ^3.0
- cakephp/cakephp: ^5.0
Requires (Dev)
- cakephp/cakephp-codesniffer: ^5.1
- cakephp/migrations: ^4.0 || ^5.0
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^10.5.5 || ^11.1.3 || ^12.0.9
Suggests
- cakephp/authentication: To use FormAuthenticator.
README
Requirements
- CakePHP >= 5.0
- CakePHP Authentication plugin
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require nojimage/cakephp-login-attempts:^3.0
Load plugin
Run the following command:
bin/cake plugin load LoginAttempts
Create table
Run migration command:
bin/cake migrations migrate -p LoginAttempts
Usage
Use LoginAttempts.Form authenticator instead of Form.
If you are using Authentication plugin:
$service->loadAuthenticator('LoginAttempts.Form', [ 'fields' => ['username' => 'email'], 'attemptLimit' => 5, 'attemptDuration' => '+5 minutes', ]);
LoginAttempts.Form Options
attemptLimit
If the number of login failures exceeds attemptLimit during attemptDuration,
the user's login is not permitted.
default: 5
attemptDuration
If the number of login failures exceeds attemptLimit during attemptDuration,
the user's login is not permitted.
default: '+5 minutes'
attemptAction
The number of attempts is stored separately for this key. Use when there are multiple login forms and you want to set restrictions separately.
default: 'login'
attemptsStorageModel
A model used for logging login failures and checking the count of failed login attempts.
default: 'LoginAttempts.Attempts'