PHPackages                             marcusyan/passport-custom-jwt-claims - 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. marcusyan/passport-custom-jwt-claims

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

marcusyan/passport-custom-jwt-claims
====================================

Customize JWT claims in Laravel Passport access tokens

0.0.5(5y ago)01.1kMITPHP

Since Apr 20Pushed 5y agoCompare

[ Source](https://github.com/Marcusyan/passport-custom-jwt-claims)[ Packagist](https://packagist.org/packages/marcusyan/passport-custom-jwt-claims)[ RSS](/packages/marcusyan-passport-custom-jwt-claims/feed)WikiDiscussions master Synced today

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

Laravel Passport Custom JWT Claims
==================================

[](#laravel-passport-custom-jwt-claims)

[![Build Status](https://camo.githubusercontent.com/8207d57e642ab2b5417e6445995a811bcaed2b74893aabb9e757cc6e0e2d86f2/68747470733a2f2f7472617669732d63692e6f72672f62656e626a75727374726f6d2f70617373706f72742d637573746f6d2d6a77742d636c61696d732e737667)](https://travis-ci.org/benbjurstrom/passport-custom-jwt-claims)Customize the JWT claims in [Laravel/Passport](https://github.com/laravel/passport) access tokens

What are JWT claims?
--------------------

[](#what-are-jwt-claims)

All access tokens issued by [Laravel/Passport](https://github.com/laravel/passport) are in fact [JSON web tokens](https://jwt.io/) (JWT). Each token contains a set of claims consisting of JSON key value pairs. Because the token is cryptographically signed using a public/private RSA key pair we can trust that the claims contained in the token were issued by Laravel/Passport.

Here is an example token containing the default Laravel/Passport claims:

```
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjllNzAxMjhmOTkwZTFlZjI0NGFmMDc0YjQzMzA2YTRmNDViZWFiNjU1MzM5NjE2ODIyOGJmODc2Y2UwM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T payload object:

```
{
  "aud": "c8e104f0-0562-11e7-905b-3d77df97f2f8",
  "jti": "9e70128f990e1ef244af074b43306a4f45beab6553396168228bf876ce01005224fa17937d0f0157",
  "iat": 1489901755,
  "nbf": 1489901755,
  "exp": 1521437755,
  "sub": "c8df99a0-0562-11e7-9082-bfd7aa3311e8",
  "scopes": []
}
```

For reference, the claim `aud` is the Laravel/Passport client\_id that issued the token and the key `sub` refers to the user id in your laravel users table. Note that my client\_id and user\_id columns are UUID data types.

Why would you need custom claims?
---------------------------------

[](#why-would-you-need-custom-claims)

The [OpenID Connect](http://openid.net/connect/) protocol requires JWT claims that are not included in Laravel/Passport access tokens. Adding custom claims allows us to use access tokens issued by Laravel/Passport to authenticate with other services using OpenID Connect. For example, with this package it is possible to use a Laravel/Passport access token to authenticate a laravel user on a [Couchbase Sync Gateway](https://developer.couchbase.com/documentation/mobile/1.4/guides/authentication/openid/index.html)server.

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

[](#installation)

Install the package via composer:

```
composer require benbjurstrom/passport-custom-jwt-claims
```

Add the service provider to the config/app.php providers array.

```
// config/app.php
'providers' => [
    ...
    BenBjurstrom\JwtClaims\JwtClaimsServiceProvider::class
];
```

Do not include `Laravel\Passport\PassportServiceProvider` in your providers array as `JwtClaimsServiceProvider` extends from it.

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

[](#configuration)

To set your custom claims you must publish the config file:

```
php artisan vendor:publish --provider="JwtClaimsServiceProvider"
```

This is the contents of the published file. Add additional claims as needed.

```
return [

    /*
    |--------------------------------------------------------------------------
    | User Claims
    |--------------------------------------------------------------------------
    |
    | User claims will be loaded from the properties of the auth providers model
    | specified in the auth config file.
    |
    */
    'user_claims' => [
        'name' => 'name',
        'email' => 'email',
    ],

    /*
    |--------------------------------------------------------------------------
    | App claims
    |--------------------------------------------------------------------------
    |
    | App claims are static and will be given the specified value across all
    | tokens issued by the app.
    |
    */
    'app_claims' => [
        'iss' => url('')
    ]

];
```

###  Health Score

28

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~300 days

Total

5

Last Release

2056d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/951a527d7660eb9b8567686247e59c03c5b281e21876b407d209a943f0306fe6?d=identicon)[Marcusyan](/maintainers/Marcusyan)

---

Top Contributors

[![benbjurstrom](https://avatars.githubusercontent.com/u/12499093?v=4)](https://github.com/benbjurstrom "benbjurstrom (4 commits)")[![Marcusyan](https://avatars.githubusercontent.com/u/8740410?v=4)](https://github.com/Marcusyan "Marcusyan (1 commits)")

---

Tags

jwtapilaravelpassportOpenIdOpenID Connectcustomoidcclaims

### Embed Badge

![Health badge](/badges/marcusyan-passport-custom-jwt-claims/health.svg)

```
[![Health](https://phpackages.com/badges/marcusyan-passport-custom-jwt-claims/health.svg)](https://phpackages.com/packages/marcusyan-passport-custom-jwt-claims)
```

###  Alternatives

[benbjurstrom/passport-custom-jwt-claims

Customize JWT claims in Laravel Passport access tokens

341.8k](/packages/benbjurstrom-passport-custom-jwt-claims)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2794.9M3](/packages/auth0-login)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

52314.4k1](/packages/jeremy379-laravel-openid-connect)[ronvanderheijden/openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

60709.0k](/packages/ronvanderheijden-openid-connect)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

41119.7M57](/packages/auth0-auth0-php)[authlete/authlete-laravel

Authlete Library for Laravel

4125.9k](/packages/authlete-authlete-laravel)

PHPackages © 2026

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