PHPackages                             marketredesign/mrd-auth0-laravel - 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. marketredesign/mrd-auth0-laravel

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

marketredesign/mrd-auth0-laravel
================================

Wrapper to easily configure Auth0 with a Laravel application

v3.1.1(2y ago)312.0k[9 PRs](https://github.com/marketredesign/mrd-auth0-laravel/pulls)MITPHPPHP ^8.1CI passing

Since Oct 12Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/marketredesign/mrd-auth0-laravel)[ Packagist](https://packagist.org/packages/marketredesign/mrd-auth0-laravel)[ Docs](https://github.com/marketredesign/mrd-auth0-laravel)[ RSS](/packages/marketredesign-mrd-auth0-laravel/feed)WikiDiscussions develop Synced 2d ago

READMEChangelog (10)Dependencies (12)Versions (34)Used By (0)

MRD Auth0 Laravel
=================

[](#mrd-auth0-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9cf8d9f6c8d94a0022cb31255e63da87ae7b931d12ab09f0517517bc1662e25b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61726b6574726564657369676e2f6d72642d61757468302d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marketredesign/mrd-auth0-laravel)[![Build Status](https://camo.githubusercontent.com/bcd9d2b8f216130076f20f773e254d2677d230279d8da6c09e0bb8df4f65c21e/68747470733a2f2f696d672e736869656c64732e696f2f617a7572652d6465766f70732f6275696c642f6d61726b6574726564657369676e2f66363566336339312d613736622d343464622d623361372d3338313562393933386530312f31392f6d61737465723f7374796c653d666c61742d737175617265)](https://dev.azure.com/marketredesign/Public%20Packages/_build?definitionId=19&_a=summary)[![Code Coverage](https://camo.githubusercontent.com/bf58a2f20a04d8efbba10ee56ce72dbb099867919148df1176b7c713084e7497/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f6d61726b6574726564657369676e2f6d72642d61757468302d6c61726176656c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/marketredesign/mrd-auth0-laravel)[![Total Downloads](https://camo.githubusercontent.com/7864313e3487803fe94607171c8ecd3bea4c83394e81990db4fa83440aefedab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61726b6574726564657369676e2f6d72642d61757468302d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marketredesign/mrd-auth0-laravel)

Wrapper to easily configure Auth0 with a Laravel application.

Also includes a logger for NewRelic.

Getting Started
---------------

[](#getting-started)

### Prerequisites

[](#prerequisites)

- PHP 7.4 or higher
- PHP JSON extension
- PHP mbstring extension
- PHP XML extension
- PHP Curl extension
- Laravel 6 or higher

### Installing

[](#installing)

You can install the package via composer:

```
composer require marketredesign/mrd-auth0-laravel
```

For configuration, the default config files can be published using the following command.

```
php artisan vendor:publish
```

Select the option for `Marketredesign\MrdAuth0Laravel\MrdAuth0LaravelServiceProvider`. This creates the config file `config/mrd-auth0.php`.

Upgrade to v2
-------------

[](#upgrade-to-v2)

See the [UPGRADE](UPGRADE.md) guide for instructions when updating an application that uses v1 to v2.

Usage
-----

[](#usage)

See [laravel-auth0](https://github.com/auth0/laravel-auth0) for instructions on how to configure authentication / authorization of users.

### Authorizing dataset access

[](#authorizing-dataset-access)

Add the `dataset.access` middleware to the API route. Then, make sure the dataset ID is specified using either `dataset_id` or `datasetId`. It can be part of the route itself or part of the request data (query param, request body, etc.)

### Requesting machine-to-machine tokens from Auth0

[](#requesting-machine-to-machine-tokens-from-auth0)

Use `Auth0` facade. Can be used to retrieve a machine-to-machine token, only when running in console (e.g. from async job). The tokens are automatically cached for half their expiration time. When testing a function that retrieves a m2m token, execute `Auth0::fake()` to use a mocked Auth0Repository which does not make any API calls to Auth0. The fake repository can be influenced using the `Auth0::fake...()` functions.

### User repository

[](#user-repository)

Use `Users` facade. Can be used to retrieve a single user, or multiple users, by ID. Also includes functionality to retrieve multiple users by email addresses. When testing a function that uses the UserRepository (or Facade), execute `Users::fake()` to use a mocked UserRepository which does not make any API calls to Auth0. The fake repository can be influenced using `Users::fake...()` methods.

### Dataset repository

[](#dataset-repository)

Use `Datasets` facade. Can be used to retrieve authorized datasets for the current user making the API request. When testing a function that uses the DatasetRepository (or Datasets facade), execute `Datasets::fake()` to use a mocked version of the DatasetRepository that does not make any API calls to the underlying user tool API. The fake repository can be influenced using the `Datasets::fake...()` methods.

### Logging to NewRelic

[](#logging-to-newrelic)

Create a new logger in the `config/logging.php` file (example code below) and make sure that the `NEWRELIC_LICENSE_KEY`is set. Then, this logger can be selected as any other logger, for example by setting the `LOG_CHANNEL` to `'newrelic'`.

This logger looks for optional `app.repository` and `app.version` config values to log along with every logged message, so add those fields to the `config/app.php` file if you want this to be included.

Example codeLogger for in `config/logging.php`:

```
'newrelic' => [
    'driver' => 'custom',
    'via' => \Marketredesign\MrdAuth0Laravel\Logging\NewRelicLogger::class,
    'license_key' => env('NEWRELIC_LICENSE_KEY'),
],
```

Optional `app.repository` and `app.version` config values for in `config/app.php`:

```
    /*
    |--------------------------------------------------------------------------
    | Repository Name
    |--------------------------------------------------------------------------
    |
    | The name of the repository this application is an instance of.
    | Used for example when logging to NewRelic.
    |
    */
    'repository' => 'your-repository-name-here',

    /*
    |--------------------------------------------------------------------------
    | Application Version
    |--------------------------------------------------------------------------
    |
    | Version name of the code currently. When developing, this will be local.
    | When the code is being built, a version.txt document at the root should
    | be created containing the version number (or other build specification
    | such as the commit hash), which is then loaded into this config variable.
    |
    */
    'version' => file_exists('../version.txt') ? file('../version.txt')[0] : 'local',
```

Running the tests
-----------------

[](#running-the-tests)

Simply run:

```
vendor/bin/phpunit
```

Authors
-------

[](#authors)

- **Marijn van der Horst** - *Initial work*

See also the list of [contributors](https://github.com/marketredesign/mrd-auth0-laravel/contributors) who participated in this project.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance54

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~49 days

Recently: every ~21 days

Total

21

Last Release

1044d ago

Major Versions

v1.8.0 → v2.0.02022-05-16

v2.3.0 → v3.0.02023-04-08

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

v1.5.2PHP ^7.4|^8.0

v2.2.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c29223f7ac7727b7769e5ad60fcfb6b21adf78ac330026fa41083c388278ab73?d=identicon)[marmel](/maintainers/marmel)

---

Top Contributors

[![marijnvanderhorst](https://avatars.githubusercontent.com/u/7057618?v=4)](https://github.com/marijnvanderhorst "marijnvanderhorst (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![KadirMarangoz](https://avatars.githubusercontent.com/u/38736432?v=4)](https://github.com/KadirMarangoz "KadirMarangoz (4 commits)")[![SquarePlayn](https://avatars.githubusercontent.com/u/7192111?v=4)](https://github.com/SquarePlayn "SquarePlayn (4 commits)")[![EmielSchmeink](https://avatars.githubusercontent.com/u/6396768?v=4)](https://github.com/EmielSchmeink "EmielSchmeink (1 commits)")

---

Tags

marketredesignmrd-auth0-laravel

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/marketredesign-mrd-auth0-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/marketredesign-mrd-auth0-laravel/health.svg)](https://phpackages.com/packages/marketredesign-mrd-auth0-laravel)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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