PHPackages                             descom/laravel-auth-spa - 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. descom/laravel-auth-spa

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

descom/laravel-auth-spa
=======================

Template to generate a Laravel Package

4.0.2(1y ago)01.1k↓33.3%1MITPHPPHP ^8.2

Since Jun 15Pushed 1y agoCompare

[ Source](https://github.com/descom-es/laravel-auth-spa)[ Packagist](https://packagist.org/packages/descom/laravel-auth-spa)[ RSS](/packages/descom-laravel-auth-spa/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (12)Used By (0)

Laravel Auth SPA
================

[](#laravel-auth-spa)

[![tests](https://github.com/descom-es/laravel-auth-spa/actions/workflows/tests.yml/badge.svg)](https://github.com/descom-es/laravel-auth-spa/actions/workflows/tests.yml)[![analyse](https://github.com/descom-es/laravel-auth-spa/actions/workflows/analyse.yml/badge.svg)](https://github.com/descom-es/laravel-auth-spa/actions/workflows/analyse.yml)[![style](https://github.com/descom-es/laravel-auth-spa/actions/workflows/style.yml/badge.svg)](https://github.com/descom-es/laravel-auth-spa/actions/workflows/style.yml)

This package is an authentication backend implementation for Laravel. Registers the routes and controllers required to implement all Laravel authentication features from a Frontend SPA or SSR, including login, password reset, and more.

- [Installation](#installation)
- [Configure](#configure)
    - [Laravel Sanctum](#laravel-sanctum)
    - [Package](#package)
- [Usage](#usage)
    - [Login](#login)
    - [Logout](#logout)
    - [Get reset password link](#get-reset-password-link)
    - [Reset password with link](#reset-password-with-link)
    - [Update password for current user logged](#update-password-for-current-user-logged)
- [Customize](#customize)
    - [Defining Default Password Rules](#defining-default-password-rules)
- [More info](#more-info)

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

[](#installation)

```
composer require descom/laravel-auth-spa
```

Configure
---------

[](#configure)

### Laravel Sanctum

[](#laravel-sanctum)

Run:

```
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate
```

Add Sanctum's middleware to your api middleware group within your application's `app/Http/Kernel.php` file:

```
'api' => [
    \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
    'throttle:api',
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
],
```

Configure cors, you need edit the file `config/cors.php` and change this lines:

```
    'paths' => ['api/*', 'sanctum/csrf-cookie', 'login', 'logout', 'password/forget', 'password/reset'],

    /// ...

    'supports_credentials' => true,
```

In production define this environment variables:

Local:

```
SANCTUM_STATEFUL_DOMAINS=localhost:3000
SESSION_DOMAIN=localhost
```

Production for domain '[www.app.tld](http://www.app.tld)':

```
SANCTUM_STATEFUL_DOMAINS=www.app.tld
SESSION_DOMAIN=.app.tld
```

### Package

[](#package)

```
php artisan vendor:publish --provider="Descom\AuthSpa\AuthSpaServiceProvider" --tag="config"
```

You can define your frontend in config file `config/authspa.php`

```
///
    'frontend' => [
        'url' => env('FRONTEND_URL', 'http://localhost:3000'),

        'reset_password_url' => env('FRONTEND_RESET_PASSWORD_URL', '/login/reset'),
    ],
///
```

Usage
-----

[](#usage)

### Login

[](#login)

```
POST /login

{
    "email": " ",
    "password": ""
}
```

### Logout

[](#logout)

```
POST /logout
```

### Get reset password link

[](#get-reset-password-link)

```
POST /password/forgot

{
    "email": " "
}
```

### Reset password with link

[](#reset-password-with-link)

```
POST /password/reset

{
    "token": "",
    "email": " ",
    "password": "",
    "password_confirmation": ""
}
```

### Update password for current user logged

[](#update-password-for-current-user-logged)

```
PUT /api/user/password

{
    "current_password": "",
    "password": "",
    "password_confirmation": ""
}
```

### Get user info

[](#get-user-info)

```
GET /api/user
```

### Nuxt.js

[](#nuxtjs)

Install Nuxt Auth:

```
yarn add --exact @nuxtjs/auth-next
yarn add @nuxtjs/axios
```

And configure file `nuxt.config.js`:

```
{
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/auth-next'
  ],
  auth: {
    strategies: {
      laravelSanctum: {
        provider: 'laravel/sanctum',
        url: process.env.API_URL || 'http://localhost:8000',
      },
    },
  }
}
```

Customize
---------

[](#customize)

### Defining Default Password Rules

[](#defining-default-password-rules)

You may find it convenient to specify the default validation rules for passwords in a single location of your application. You can easily accomplish this using the `Password::defaults` method, which accepts a closure. The closure given to the defaults method should return the default configuration of the Password rule. Typically, the `defaults` rule should be called within the `boot` method of one of your application's service providers:

```
use Illuminate\Validation\Rules\Password;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Password::defaults(function () {
        $rule = Password::min(8);

        return $this->app->isProduction()
                    ? $rule->mixedCase()->uncompromised()
                    : $rule;
    });
}
```

[Other rules](https://laravel.com/docs/validation#validating-passwords)

More info
---------

[](#more-info)

- [Laravel Sanctum](https://laravel.com/docs/sanctum)
- [Nuxt Auth](https://auth.nuxtjs.org/providers/laravel-sanctum)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95.2% 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 ~75 days

Total

11

Last Release

677d ago

Major Versions

v1.0.1 → v2.0.02022-07-16

v2.2.0 → 3.0.02023-09-17

3.0.1 → 4.0.02024-07-10

PHP version history (3 changes)v1.0.0PHP ^8.0

v2.2.0PHP ^8.1

4.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25681494?v=4)[Cesar Garcia](/maintainers/cesargb)[@cesargb](https://github.com/cesargb)

---

Top Contributors

[![cesargb](https://avatars.githubusercontent.com/u/25681494?v=4)](https://github.com/cesargb "cesargb (60 commits)")[![TortitasT](https://avatars.githubusercontent.com/u/76071376?v=4)](https://github.com/TortitasT "TortitasT (3 commits)")

---

Tags

authlaravelnuxt

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/descom-laravel-auth-spa/health.svg)

```
[![Health](https://phpackages.com/badges/descom-laravel-auth-spa/health.svg)](https://phpackages.com/packages/descom-laravel-auth-spa)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[overtrue/laravel-follow

User follow unfollow system for Laravel.

1.2k404.7k5](/packages/overtrue-laravel-follow)[tuandm/laravue

A beautiful dashboard for Laravel built by VueJS

2.2k16.6k](/packages/tuandm-laravue)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)

PHPackages © 2026

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