PHPackages                             oxid-esales/jwt-authentication-component - 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. oxid-esales/jwt-authentication-component

ActiveOxideshop-component[Authentication &amp; Authorization](/categories/authentication)

oxid-esales/jwt-authentication-component
========================================

Authentication component for OXID eShop with JWT support

v1.0.0(3mo ago)02011proprietaryPHPPHP ^8.3CI passing

Since Apr 8Pushed 1mo agoCompare

[ Source](https://github.com/OXID-eSales/jwt-authentication-component)[ Packagist](https://packagist.org/packages/oxid-esales/jwt-authentication-component)[ RSS](/packages/oxid-esales-jwt-authentication-component/feed)WikiDiscussions b-7.5.x Synced 3w ago

READMEChangelogDependencies (8)Versions (3)Used By (1)

OXID eShop JWT Authentication Component
=======================================

[](#oxid-eshop-jwt-authentication-component)

JWT-based authentication component for OXID eShop API endpoints.

Features
--------

[](#features)

- JWT token generation and validation
- Integration with OXID user system
- Role-based access control with Symfony Security
- `#[IsGranted]` and `#[CurrentUser]` attributes for protecting endpoints
- Ready-to-use login and profile endpoints

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

[](#installation)

```
composer require oxid-esales/jwt-authentication-component
```

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

[](#configuration)

Set the JWT secret key in your `.env` file:

```
API_JWT_SECRET=your-secret-key-here
```

Generate a secure secret:

```
openssl rand -base64 64
```

### Token Expiration

[](#token-expiration)

Default token lifetime is 3600 seconds (1 hour). Override via parameter:

```
parameters:
  oxid_jwt_authenticator.token_expiration_seconds: 7200
```

Usage
-----

[](#usage)

### Login

[](#login)

```
curl -X POST https://your-shop.com/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": "user@example.com", "password": "password"}'
```

To authenticate against a specific subshop, pass the `shp` query parameter:

```
curl -X POST "https://your-shop.com/api/login?shp=2" \
  -H "Content-Type: application/json" \
  -d '{"username": "user@example.com", "password": "password"}'
```

Response:

```
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
  "user": {
    "username": "user@example.com",
    "roles": ["ROLE_USER"]
  }
}
```

### Protecting Endpoints

[](#protecting-endpoints)

Use Symfony's `#[IsGranted]` attribute to protect endpoints:

```
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

final readonly class MyApiController
{
    #[Route('/api/protected', methods: ['GET'])]
    #[IsGranted('IS_AUTHENTICATED')]
    public function getData(): Response
    {
        // Requires authentication
    }

    #[Route('/api/admin/settings', methods: ['GET'])]
    #[IsGranted('ROLE_ADMIN')]
    public function getSettings(): Response
    {
        // Requires ROLE_ADMIN
    }
}
```

### Accessing Authenticated User

[](#accessing-authenticated-user)

```
use OxidEsales\AuthComponent\Security\User\ApiUser;
use Symfony\Component\Security\Http\Attribute\CurrentUser;

public function getData(#[CurrentUser] ApiUser $user): Response
{
    return new JsonResponse([
        'username' => $user->getUserIdentifier(),
        'roles' => $user->getRoles()
    ]);
}
```

Available Roles
---------------

[](#available-roles)

- `ROLE_USER` - All authenticated users
- `ROLE_ADMIN` - Admin users
- `ROLE_ADMIN_MALL` - Mall admin users

Role Hierarchy
--------------

[](#role-hierarchy)

The component includes a configurable role hierarchy. By default, `ROLE_ADMIN_MALL` inherits `ROLE_ADMIN`, meaning mall admins can access all admin endpoints.

Default configuration in `services.yaml`:

```
parameters:
  oxid_jwt_authenticator.role_hierarchy:
    ROLE_ADMIN_MALL:
      - ROLE_ADMIN
```

For more complex role hierarchies, implement `RoleResolverInterface` with custom resolution logic.

License
-------

[](#license)

Proprietary

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance88

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

108d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1374817?v=4)[oxid](/maintainers/oxid)[@OxID](https://github.com/OxID)

---

Top Contributors

[![godefroy-le-hardi](https://avatars.githubusercontent.com/u/31134636?v=4)](https://github.com/godefroy-le-hardi "godefroy-le-hardi (5 commits)")

---

Tags

jwtapisecurityAuthenticationOXID

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oxid-esales-jwt-authentication-component/health.svg)

```
[![Health](https://phpackages.com/badges/oxid-esales-jwt-authentication-component/health.svg)](https://phpackages.com/packages/oxid-esales-jwt-authentication-component)
```

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k185.6M2.4k](/packages/symfony-security-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.2k18.1k](/packages/prestashop-prestashop)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.8k](/packages/symfony-framework-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M600](/packages/shopware-core)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M754](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)

PHPackages © 2026

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