{"id":36988238,"url":"https://github.com/juliomotol/laravel-auth-timeout","last_synced_at":"2026-01-13T23:25:03.411Z","repository":{"id":55137895,"uuid":"252781961","full_name":"juliomotol/laravel-auth-timeout","owner":"juliomotol","description":"Authentication Timeout for Laravel","archived":false,"fork":false,"pushed_at":"2025-03-02T12:43:18.000Z","size":159,"stargazers_count":41,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-30T07:13:50.512Z","etag":null,"topics":["authentication","laravel","middleware","timeout"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliomotol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-03T16:17:28.000Z","updated_at":"2025-03-02T13:09:05.000Z","dependencies_parsed_at":"2024-04-01T19:29:22.616Z","dependency_job_id":"17958d5a-3400-443b-bd95-1b7edb32cc37","html_url":"https://github.com/juliomotol/laravel-auth-timeout","commit_stats":{"total_commits":81,"total_committers":5,"mean_commits":16.2,"dds":0.4320987654320988,"last_synced_commit":"45d6388251804ce5e291cb1e04e27367853e893e"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/juliomotol/laravel-auth-timeout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliomotol%2Flaravel-auth-timeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliomotol%2Flaravel-auth-timeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliomotol%2Flaravel-auth-timeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliomotol%2Flaravel-auth-timeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliomotol","download_url":"https://codeload.github.com/juliomotol/laravel-auth-timeout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliomotol%2Flaravel-auth-timeout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","laravel","middleware","timeout"],"created_at":"2026-01-13T23:25:02.782Z","updated_at":"2026-01-13T23:25:03.405Z","avatar_url":"https://github.com/juliomotol.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Auth Timeout\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/juliomotol/laravel-auth-timeout.svg?style=flat-square)](https://packagist.org/packages/juliomotol/laravel-auth-timeout)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/juliomotol/laravel-auth-timeout/run-tests.yml?branch=master\u0026label=tests\u0026style=flat-square)](https://github.com/juliomotol/laravel-auth-timeout/actions?query=workflow%3Arun-tests+branch%3Amaster)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/juliomotol/laravel-auth-timeout/fix-php-code-style-issues.yml?branch=master\u0026label=code%20style\u0026style=flat-square)](https://github.com/juliomotol/laravel-auth-timeout/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amaster)\n[![Total Downloads](https://img.shields.io/packagist/dt/juliomotol/laravel-auth-timeout.svg?style=flat-square)](https://packagist.org/packages/juliomotol/laravel-auth-timeout)\n\nHandle Authentication timeouts in Laravel.\n\n\u003e When upgrading to v4, please see the [CHANGELOG.md](./CHANGELOG.md).\n\n\u003e For Laravel 8+ support, see [v3](https://github.com/juliomotol/laravel-auth-timeout/tree/v3).\n\u003e\n\u003e For Laravel 6+ support, see [v2](https://github.com/juliomotol/laravel-auth-timeout/tree/v2).\n\n## Why Laravel Auth Timeout?\n\nThere are times where we want to log out a user when they haven't done any request within a set time. There is a workaround (below):\n\n```\n/* Somewhere in config/session.php */\n'lifetime' =\u003e 15,\n```\n\nBut this affects the entirety of the session. But it doesnt have to be and that is where Laravel Auth Timeout comes in.\n\nLaravel Auth Timeout is a small middleware package that checks if the user had made any request in a set of time. If they have reached the idle time limit, they are then logged out on their next request. Thanks to Brian Matovu's [article](http://bmatovu.com/laravel-session-timeout-auto-logout/).\n\n## Installation\n\nYou can install the package via composer:\n\n```sh\ncomposer require juliomotol/laravel-auth-timeout\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"auth-timeout-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\n\u003c?php\n\nreturn [\n\n    /**\n     * The session name used to identify if the user has reached the timeout time.\n     */\n    'session' =\u003e 'last_activity_time',\n\n\n    /**\n     * The minutes of idle time before the user is logged out.\n     */\n    'timeout' =\u003e 15,\n\n    /**\n     * The event that will be dispatched when a user has timed out.\n     */\n    'event' =\u003e JulioMotol\\AuthTimeout\\Events\\AuthTimedOut::class,\n\n];\n```\n\n## Usage\n\n### Quick Start\n\nFor a simple usage, register the `CheckAuthTimeout` in your `Kernel.php`.\n\n```php\nprotected $routeMiddleware = [\n    ...\n    'auth.timeout' =\u003e \\JulioMotol\\AuthTimeout\\Middlewares\\CheckAuthTimeout::class,\n    ...\n];\n```\n\nThen use that middleware on a route.\n\n```php\nRoute::get('/admin', [\n    'uses' =\u003e 'FooBarController@Foobar',\n    'middleware' =\u003e ['auth.timeout']\n]);\n```\n\n### Using Different Guards\n\nYou might have multiple guards and only want to apply `CheckAuthTimeout` to certain ones. We got you covered, `CheckAuthTimeout` accepts a `$guard` parameter.\n\n```php\nRoute::get('/admin', [\n    'uses' =\u003e 'FooBarController@Foobar',\n    'middleware' =\u003e ['auth.timeout:custom-guard'] // Add the guard name as a parameter for the auth.timeout middleware.\n]);\n```\n\n\u003e NOTE: This package only works with guards that uses a `session` driver.\n\n### AuthTimedOut\n\nAn `AuthTimedOut` will be dispatch every time a user has timed out. You can assign a listener for this event in your `EventServiceProvider`.\n\n```php\nprotected $listen = [\n    \\JulioMotol\\AuthTimeout\\Events\\AuthTimedOut::class =\u003e [\n        // ...\n    ],\n];\n```\n\n`AuthTimedOut` has two properties that you can access in your `EventListener`.\n\n```php\nclass FooEventListener\n{\n    public function handle(AuthTimedOut $event)\n    {\n        $event-\u003euser;\n        $event-\u003eguard;\n    }\n}\n```\n\n### Redirection\n\nTo modify the redirection when a user has timed out, you can use `CheckAuthTimeout::setRedirectTo()` within your `AppServiceProvider` to set a redirection callback.\n\n```php\nclass AppServiceProvider extends ServiceProvider\n{\n    public function boot()\n    {\n        CheckAuthTimeout::setRedirectTo(function ($request, $guard){\n            return match($guard){\n                'custom-guard' =\u003e route('some.route'),\n                default =\u003e route('auth.login')\n            };\n        });\n    }\n}\n```\n\n### AuthTimeout Facade\n\nThis package also provides a facade with the following methods:\n\n```php\nAuthTimeout::init() // Initialize the timeout session when no has been set yet.\n\nAuthTimeout::check($guard) // Check if a user has timed out and logs them out if so.\n\nAuthTimeout::hit() // Reset the user's timeout session.\n\nAuthTimeout::lastActiveAt() // The last activity time of the user.\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Julio Motol](https://github.com/juliomotol)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliomotol%2Flaravel-auth-timeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliomotol%2Flaravel-auth-timeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliomotol%2Flaravel-auth-timeout/lists"}