PHPackages                             browner12/reauthenticate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. browner12/reauthenticate

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

browner12/reauthenticate
========================

reauthenticate your users on higher security pages

v1.2.0(5y ago)281.0k4[1 issues](https://github.com/browner12/reauthenticate/issues)MITPHPPHP ^7.2CI failing

Since Sep 29Pushed 5y ago2 watchersCompare

[ Source](https://github.com/browner12/reauthenticate)[ Packagist](https://packagist.org/packages/browner12/reauthenticate)[ Docs](https://github.com/browner12/reauthenticate)[ RSS](/packages/browner12-reauthenticate/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

Reauthenticate
==============

[](#reauthenticate)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f8966ddfb1bbff3ea9b84c0e2e741e9dd56e38b235dd3230e674afb544bdfdce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62726f776e657231322f726561757468656e7469636174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/browner12/reauthenticate)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ccdbc8dadac6c074f6d11ef802edbc895a30c9455cd978d0eb989b42d5b33468/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62726f776e657231322f726561757468656e7469636174652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/browner12/reauthenticate)[![Coverage Status](https://camo.githubusercontent.com/a81415b0d0fb52b589650035a30c3275d0a80572d540716eb24cf9ec0c1e82a9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f62726f776e657231322f726561757468656e7469636174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/browner12/reauthenticate/code-structure)[![Quality Score](https://camo.githubusercontent.com/d095e5a219687cf9c143df8a741769aebf98ef91a412ceb40c8830721c48e9e2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f62726f776e657231322f726561757468656e7469636174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/browner12/reauthenticate)[![Total Downloads](https://camo.githubusercontent.com/676238c964c443cba7dbdc2a6136b768833c074b489493a2001e0464472512bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62726f776e657231322f726561757468656e7469636174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/browner12/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
-------

[](#install)

Via Composer

```
$ composer require browner12/reauthenticate
```

Setup
-----

[](#setup)

Add the service provider to the providers array in `config/app.php`.

```
'providers' => [
    browner12\reauthenticate\ReauthenticateServiceProvider::class,
];
```

If you are using Laravel's automatic package discovery, you can skip this step.

Publishing
----------

[](#publishing)

While we provide sensible defaults, if you would like to customize this package simply publish the config file with the following command.

```
php artisan vendor:publish --provider="browner12\reauthenticate\ReauthenticateServiceProvider"
```

Wiring
------

[](#wiring)

Let's start by adding our new middleware to `App\Http\Kernel.php`.

```
protected $routeMiddleware = [
    'auth'           => \Illuminate\Auth\Middleware\Authenticate::class,
    'auth.basic'     => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'bindings'       => \Illuminate\Routing\Middleware\SubstituteBindings::class,
    'can'            => \Illuminate\Auth\Middleware\Authorize::class,
    'guest'          => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle'       => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    'reauthenticate' => \browner12\reauthenticate\Reauthenticate::class,
];
```

We will need 2 routes for our reauthentication. One to show the form to enter a password, and another to process the input.

```
Route::get('reauthenticate', 'ReauthenticateController@reauthenticate')->name('reauthenticate');
Route::post('reauthenticate', 'ReauthenticateController@processReauthenticate')->name('reauthenticate.process');
```

Now let's make the associated controller:

```
php artisan make:controller ReauthenticateController
```

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. Returns `false` on failure.
- `resetReauthenticationTimer()` - Stores the current time in the session as the last successful authentication.

Now we will use this trait in our controller.

```
namespace App\Http\Controllers;

use browner12\reauthenticate\Concerns\Reauthenticates;
use Illuminate\Http\Request;

class ReauthenticateController extends Controller
{
    use Reauthenticates;

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function reauthenticate()
    {
        //load view
        return view('main/auth/reauthenticate');
    }

    /**
     * @param \Illuminate\Http\Request             $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function processReauthenticate(Request $request)
    {
        //good password
        if ($url = $this->checkReauthenticationPassword($request->get('password'), $request->user()->password)){

            return redirect()->to($url);
        }

        //send back
        return back();
    }
}
```

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
-----

[](#usage)

Using the reauthentication feature is incredibly easy. Simply add the middleware to either your routes:

```
Route::get('users', 'UserController')->middleware('reauthenticate');
```

or your controllers:

```
class UserController extends Controller
{
    /**
     * constructor
     */
    public function __construct()
    {
        //parent
        parent::__construct();

        //middleware
        $this->middleware('auth');

        //reauthenticate
        $this->middleware('reauthenticate')->only(['index']);
    }
}
```

Limitations
-----------

[](#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
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Andrew Brown](https://github.com/browner12)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 69.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~269 days

Total

5

Last Release

2071d ago

Major Versions

v0.1.1 → v1.0.02019-09-09

PHP version history (2 changes)v0.1.0PHP ~5.6|~7.0

v1.0.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/fa26eb2ff60e4c5077e691d2b0b83bd76051e22a8b26329f873017dc8e8d1b03?d=identicon)[browner12](/maintainers/browner12)

---

Top Contributors

[![browner12](https://avatars.githubusercontent.com/u/5232313?v=4)](https://github.com/browner12 "browner12 (25 commits)")[![markvesterskov](https://avatars.githubusercontent.com/u/7515900?v=4)](https://github.com/markvesterskov "markvesterskov (7 commits)")[![ivuorinen](https://avatars.githubusercontent.com/u/11024?v=4)](https://github.com/ivuorinen "ivuorinen (3 commits)")[![oriceon](https://avatars.githubusercontent.com/u/358823?v=4)](https://github.com/oriceon "oriceon (1 commits)")

---

Tags

browner12reauthenticate

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/browner12-reauthenticate/health.svg)

```
[![Health](https://phpackages.com/badges/browner12-reauthenticate/health.svg)](https://phpackages.com/packages/browner12-reauthenticate)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[casbin/laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.

324339.9k4](/packages/casbin-laravel-authz)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
