PHPackages                             sbh/jwt-forwarding-bundle - 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. sbh/jwt-forwarding-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

sbh/jwt-forwarding-bundle
=========================

Automatically forwards JWT tokens between Symfony microservices via HttpClient.

00PHP

Since Jun 12Pushed 11mo agoCompare

[ Source](https://github.com/saidbh/Jwt-forwarding-bundle)[ Packagist](https://packagist.org/packages/sbh/jwt-forwarding-bundle)[ RSS](/packages/sbh-jwt-forwarding-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SbhJwtForwardingBundle
======================

[](#sbhjwtforwardingbundle)

**Automatically forwards JWT tokens between Symfony microservices when using `HttpClientInterface`.**

If a user is authenticated with a Bearer token, this bundle ensures that all internal HTTP calls between services automatically propagate the JWT.
You no longer need to manually pass `Authorization` headers.

---

Features
--------

[](#features)

✅ Automatically captures JWT from incoming requests
✅ Automatically forwards JWT when using Symfony `HttpClientInterface`
✅ Transparent: your services remain unchanged
✅ Lightweight — no external dependencies
✅ Compatible with Symfony 5.4, 6.x, 7.x
✅ Easy to extend and configure

---

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

[](#installation)

```
composer require sbh/jwt-forwarding-bundle
```

Bundle Configuration
====================

[](#bundle-configuration)

1️⃣ Register services

```
services:
    Sbh\JwtForwardingBundle\Service\JwtStorage: ~

    Sbh\JwtForwardingBundle\EventListener\StoreJwtListener:
        tags:
            - { name: kernel.event_listener, event: kernel.request, priority: 100 }

    Sbh\JwtForwardingBundle\Http\JwtForwardingHttpClient:
        decorates: 'http_client'
        arguments:
            - '@Sbh\JwtForwardingBundle\Http\JwtForwardingHttpClient.inner'
            - '@Sbh\JwtForwardingBundle\Service\JwtStorage'
```

2️⃣ Usage in your services

```
use Symfony\Contracts\HttpClient\HttpClientInterface;

class MyService
{
    public function __construct(private HttpClientInterface $httpClient) {}

    public function callOtherService(): void
    {
        $response = $this->httpClient->request('GET', 'http://service-b.local/api/data');
        $data = $response->toArray();

        // $data contains the response from Service B, with JWT automatically forwarded
    }
}

→ You don't need to pass Authorization manually — the bundle handles it transparently.
```

How it works
============

[](#how-it-works)

- StoreJwtListener listens to kernel.request, captures the current JWT:

```
Authorization: Bearer xxxxx.yyyyy.zzzzz
```

- JwtStorage stores the token temporarily for the current request.
- JwtForwardingHttpClient decorates HttpClientInterface, and automatically injects the token in:

```
Authorization: Bearer xxxxx.yyyyy.zzzzz

→ All internal HTTP calls will receive the token automatically.
```

Typical use case
================

[](#typical-use-case)

- Microservice architecture:

```
Client → API Gateway (Symfony) → Service A → Service B

The same JWT token is forwarded:

From Client → API Gateway → automatic (default Symfony behavior)

From API Gateway (or Service A) → Service B → this bundle forwards the token ✅
```

Requirements
============

[](#requirements)

- Symfony 5.4, 6.x, or 7.x
- PHP 8.1+

Testing
=======

[](#testing)

- Run unit tests:

```
vendor/bin/phpunit
```

- Example test available: tests/JwtStorageTest.php

Roadmap / Ideas
===============

[](#roadmap--ideas)

- Provide config to exclude forwarding on some domains
- Provide logging / tracing (Monolog)
- Provide options to handle token refresh
- Provide options for custom header names (ex: X-Auth-Token)

Credits
=======

[](#credits)

- Developed by Said Ben Hmed

License
=======

[](#license)

- MIT License.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![sbenhmed](https://avatars.githubusercontent.com/u/152482138?v=4)](https://github.com/sbenhmed "sbenhmed (1 commits)")

### Embed Badge

![Health badge](/badges/sbh-jwt-forwarding-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sbh-jwt-forwarding-bundle/health.svg)](https://phpackages.com/packages/sbh-jwt-forwarding-bundle)
```

###  Alternatives

[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)[illuminate/auth

The Illuminate Auth package.

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

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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