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

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

randomstate/laravel-auth
========================

Strategy-based authentication for Laravel

v1.0.1(6y ago)0712MITPHP

Since May 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/randomstate/laravel-auth)[ Packagist](https://packagist.org/packages/randomstate/laravel-auth)[ RSS](/packages/randomstate-laravel-auth/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (5)Used By (2)

laravel-auth
============

[](#laravel-auth)

A strategy-based auth component for Laravel.

Setup with Laravel
==================

[](#setup-with-laravel)

Add `RandomState\LaravelAuth\LaravelAuthServiceProvider::class` to your app.php 'providers' config.

Strategies
==========

[](#strategies)

In a service provider:

```
public function register() {
    $this->app->resolving(AuthManager::class, function($manager) {
        $manager->register('jwt', $this->app->make(JwtStrategy::class));
    });

    $this->app->resolving(JwtStrategy::class, function($strategy) {
        $strategy->convertUsing(function(JwtUser $jwtUser) {
            return new MyUser($jwtUser);
        });
    });
}
```

Writing a Custom Strategy
-------------------------

[](#writing-a-custom-strategy)

Strategies are relatively easy to implement, though you need a firm grasp of how your authentication mechanism works before you should write a strategy for it. This library doesn't protect you from any security holes you implement by accident.

Your strategy should implement the interface `RandomState\LaravelAuth\AuthStrategy`. A convenient `RandomState\LaravelAuth\AbstractAuthStrategy` class is provided to help with this. There are two methods in this interface that must be implemented and are explained below.

```
/*
 * This method is responsible for authenticating a given Laravel HTTP Request.
 * You have access to the entire request and can choose to manipulate the request's response property to your liking.
 * For more complex flows such as OAuth2, you can still implement these in a single strategy by
 * checking for access tokens in the URL and performing different redirect logic. Only when everything is in the URL for a final
 * step should you then authenticate and allow a user through. See some of the Random State strategies for examples on how to do this.
 */
public function attempt(Request $request);

/*
 * If you use the AbstractAuthStrategy class to help you, you can ignore this method.
 *
 * The strategy system works well when it is isolated to its own domain. You should usually expose strategy specific objects
 * to represent the client or user that is authenticating/authenticated. This might be a FirebaseUser, a StripeUser,
 * a GitHub user etc.
 *
 * This function should take the (possibly-null) authenticated object returned by your attempt method and convert it into a
 * user object you can use in your application.
 */
public function convert($user);

/*
 * This method is only present in the AbstractAuthStrategy class, if you are extending that class.
 *
 * Strategies made for open source or third party use will benefit greatly from this API.
 * It allows a consumer to pass a function to convert the domain-specific user (e.g. FirebaseUser) to their own domain.
 *
 * This is especially useful for third-party consumers simply because you don't need to know the structure of their application
 * ahead of creating the strategy implementation.
 */
public function convertUsing(Closure $converter);
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~187 days

Total

3

Last Release

2552d ago

Major Versions

v0.1.0 → v1.0.02018-08-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/1204796510f0f912ac6f85359e20efbc78e573c00c742a3a53f509f3abdc7f9f?d=identicon)[CImrie](/maintainers/CImrie)

---

Top Contributors

[![byfoz](https://avatars.githubusercontent.com/u/3436576?v=4)](https://github.com/byfoz "byfoz (10 commits)")

---

Tags

authauthenticationlaravelstrategy

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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