PHPackages                             jorgemudry/laravel-remote-token-auth - 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. jorgemudry/laravel-remote-token-auth

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

jorgemudry/laravel-remote-token-auth
====================================

This package provides a hassle-free way to incorporate authentication in your application by integrating with an external api.

0.5.1(3y ago)325[1 PRs](https://github.com/jorgemudry/laravel-remote-token-auth/pulls)MITPHPPHP ^8.0

Since Mar 1Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/jorgemudry/laravel-remote-token-auth)[ Packagist](https://packagist.org/packages/jorgemudry/laravel-remote-token-auth)[ Docs](https://github.com/jorgemudry/laravel-remote-token-auth)[ RSS](/packages/jorgemudry-laravel-remote-token-auth/feed)WikiDiscussions master Synced today

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

Laravel Remote Token Auth
=========================

[](#laravel-remote-token-auth)

[![Build Status](https://camo.githubusercontent.com/c96c3eb82d4b6495ae4da92b8f1c91b31a1b1dec12ed4e23b4a4180b7a86a263/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f7267656d756472792f6c61726176656c2d72656d6f74652d746f6b656e2d617574682f6d61696e2e796d6c3f6c6162656c3d6275696c64)](https://github.com/jorgemudry/laravel-remote-token-auth/actions)[![Total Downloads](https://camo.githubusercontent.com/3bda349f11347d46c0c7bcf9b64c5216610660e6ebf3cce4dc202974c149debe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f7267656d756472792f6c61726176656c2d72656d6f74652d746f6b656e2d61757468)](https://packagist.org/packages/jorgemudry/laravel-remote-token-auth)[![Latest Stable Version](https://camo.githubusercontent.com/1c9d6b2549914d1ef5c48da5a082df557fe26eba747178346b330d7db6b1fc1b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f7267656d756472792f6c61726176656c2d72656d6f74652d746f6b656e2d61757468)](https://packagist.org/packages/jorgemudry/laravel-remote-token-auth)[![License](https://camo.githubusercontent.com/b5d7886111391ea586266146d5d76e392f0ba1dc2c2ac9d5e8a3b2297897d914/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6f7267656d756472792f6c61726176656c2d72656d6f74652d746f6b656e2d61757468)](https://packagist.org/packages/jorgemudry/laravel-remote-token-auth)[![Stars](https://camo.githubusercontent.com/9a4d66898aa1c689596dfd0cc05eaf0300b3a8bda5a34cb808a2c2d6f95304ae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a6f7267656d756472792f6c61726176656c2d72656d6f74652d746f6b656e2d61757468)](https://github.com/jorgemudry/laravel-remote-token-auth)

This package provides a hassle-free way to incorporate authentication in your application by integrating with an external service.

It enables the validation of tokens to verify the authenticity of users, ensuring that only valid users gain access to your system.

With this package, you can focus on developing your application's core functionalities while the authentication process is handled seamlessly.

It simplifies the integration process, allowing you to obtain a valid user in no time.

Requirements
------------

[](#requirements)

- Laravel 8.x or higher
- PHP 8.0 or higher

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require jorgemudry/laravel-remote-token-auth
```

The package will automatically register its service provider.

You can publish the config file with:

```
php artisan vendor:publish --provider="JorgeMudry\LaravelRemoteTokenAuth\Providers\LaravelRemoteTokenAuthServiceProvider"
```

Usage
-----

[](#usage)

To require authentication for a specific route, simply add the auth middleware and specify the *rta* guard. This will ensure that only authenticated users with a valid token can access the route.

```
Route::get('/users', function (Request $request) {
    return $request->user();
})->middleware('auth:rta');
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Adapter Implementation

[](#custom-adapter-implementation)

To create a custom implementation of the class that calls the external API to validate the token, simply implement the AdapterInterface interface on your class. Then, bind the interface to your implementation in the register method of the AuthServiceProvider.

This will allow you to use your own implementation of the class for token validation.

```
