PHPackages                             mydaniel/laravel-paseto - 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. mydaniel/laravel-paseto

ActiveLaravel-package[Authentication &amp; Authorization](/categories/authentication)

mydaniel/laravel-paseto
=======================

Paseto (Platform-Agnostic Security Tokens) authentication guard for Laravel. A secure alternative to JWT.

v1.1.0(8mo ago)1237MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Aug 20Pushed 8mo agoCompare

[ Source](https://github.com/daniyousefifar/laravel-paseto)[ Packagist](https://packagist.org/packages/mydaniel/laravel-paseto)[ RSS](/packages/mydaniel-laravel-paseto/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Laravel Paseto
==============

[](#laravel-paseto)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fefa47479b519ebd87f51cf9abda652a516d588aa46b9ad3b7d4051ece11b039/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7964616e69656c2f6c61726176656c2d70617365746f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mydaniel/laravel-paseto)[![Total Downloads](https://camo.githubusercontent.com/f491127b57364edcea5ac5445c99de3e9547e7e476f70e76c2f2513ada480a7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7964616e69656c2f6c61726176656c2d70617365746f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mydaniel/laravel-paseto)[![License](https://camo.githubusercontent.com/e45c75b4c66df65b6643a58152eeaf655f1de133d2e8aeac7ed2a9b9b56d7de0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d7964616e69656c2f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://github.com/daniyousefifar/laravel-captcha/blob/master/LICENSE)

This package provides a **PASETO (Platform-Agnostic Security Tokens)** authentication guard for Laravel. It offers a modern, secure, and easy-to-use alternative to JWT (JSON Web Tokens).

Paseto tokens are encrypted and authenticated, providing better security guarantees than JWT out of the box.

Features
--------

[](#features)

- ✅ Secure, stateless authentication for your Laravel applications.
- ✅ PASETO v4 Local support (symmetric key authenticated encryption).
- ✅ Easy to configure and use.
- ✅ Token blacklist functionality to invalidate tokens upon logout.
- ✅ An artisan command to generate a secure secret key.
- ✅ Fully customizable through configuration and contracts.

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

[](#installation)

You can install the package via composer:

```
composer require mydaniel/laravel-paseto
```

Configuration
-------------

[](#configuration)

1. **Publish the configuration file:**

    This will create a `config/paseto.php` file in your project. You can customize token expiration, issuer, audience, and other claims here.

    ```
    php artisan vendor:publish --provider="MyDaniel\Paseto\PasetoServiceProvider" --tag="config"
    ```
2. **Generate a Secret Key:**

    Run the following artisan command to generate a secure, 32-byte hex-encoded key. The command will automatically add it to your `.env` file.

    ```
    php artisan paseto:generate-key
    ```

    This will add a line like this to your `.env` file:

    ```
    PASETO_SECRET_KEY="your-generated-secret-key"
    ```
3. **Configure the Auth Guard:**

    Open your `config/auth.php` file and make the following changes:

    ```
    'defaults' => [
        'guard' => 'api', // Or your default guard
        'passwords' => 'users',
    ],

    'guards' => [
        'api' => [
            'driver' => 'paseto',
            'provider' => 'users',
        ],
    ],
    ```

Usage
-----

[](#usage)

### 1. Preparing Your User Model

[](#1-preparing-your-user-model)

Add the `MyDaniel\Paseto\Contracts\PasetoSubject` contract and the `MyDaniel\Paseto\Traits\HasPaseto` trait to your `User` model.

```
