Download the PHP package browner12/reauthenticate without Composer
On this page you can find all versions of the php package browner12/reauthenticate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download browner12/reauthenticate
More information about browner12/reauthenticate
Files in browner12/reauthenticate
Package reauthenticate
Short Description reauthenticate your users on higher security pages
License MIT
Homepage https://github.com/browner12/reauthenticate
Informations about the package reauthenticate
Reauthenticate
For pages that contain more sensitive operations, sometimes you wish to have the user reauthenticate themselves. This simple package provides the tools you need to quickly implement this functionality on your website.
Install
Via Composer
Setup
Add the service provider to the providers array in config/app.php
.
If you are using Laravel's automatic package discovery, you can skip this step.
Publishing
While we provide sensible defaults, if you would like to customize this package simply publish the config file with the following command.
Wiring
Let's start by adding our new middleware to App\Http\Kernel.php
.
We will need 2 routes for our reauthentication. One to show the form to enter a password, and another to process the input.
Now let's make the associated controller:
This package offers a trait to use in your controller. This pattern gives you the flexibility to customize the controllers as you need, while also controlling the pieces that are important for the normal package operation.
The trait offers 2 methods:
checkReauthenticationPassword()
- Checks the entered password against the known hash, and returns the requested URL if successful. Returnsfalse
on failure.resetReauthenticationTimer()
- Stores the current time in the session as the last successful authentication.
Now we will use this trait in our controller.
We do not require your view to be formatted in any way, or name your inputs anything specific. In the example above, the input is named 'password', and we are pulling the current password hash off of the logged in user.
If you would like to reset the timer in any of your other controllers, for example when the user initially logs in, you can also use the resetAuthorizationTimer()
method on this trait.
Usage
Using the reauthentication feature is incredibly easy. Simply add the middleware to either your routes:
or your controllers:
Limitations
Currently this feature only works on GET requests. The reason for this is because we cannot redirect to a POST route. I do have a solution in mind that uses a dummy page with a form that automatically submits, but I am holding off to see what the interest for it is first.
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Andrew Brown
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of reauthenticate with dependencies
illuminate/console Version ^6.0|^7.0|^8.0
illuminate/http Version ^6.0|^7.0|^8.0