PHPackages                             sonata/jwt-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. sonata/jwt-auth

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

sonata/jwt-auth
===============

JWT auth module for Sonata framework

v1.0.1(4mo ago)05PHPPHP ^8.3

Since Feb 7Pushed 4mo agoCompare

[ Source](https://github.com/DimsHewiks/sonata-jwt-auth)[ Packagist](https://packagist.org/packages/sonata/jwt-auth)[ RSS](/packages/sonata-jwt-auth/feed)WikiDiscussions main Synced today

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

Sonata JWT Auth
===============

[](#sonata-jwt-auth)

JWT-модуль для Sonata Framework: авторизация, refresh-токены и базовая таблица пользователей.

Установка
---------

[](#установка)

```
composer require sonata/jwt-auth
```

Требования
----------

[](#требования)

- `sonata/framework`
- `firebase/php-jwt`
- `ext-pdo`
- Переменная `JWT_SECRET`

Миграции
--------

[](#миграции)

Модуль использует таблицы `users` и `refresh_tokens`.

Если в приложении доступна команда:

```
php bin/console jwt:install
```

Или выполните SQL вручную из файла:

```
migrations/001_create_users_and_refresh_tokens.sql

```

Эндпоинты
---------

[](#эндпоинты)

Контроллер `Sonata\JwtAuth\Controllers\AuthController` регистрируется автоматически:

- `POST /api/login` — логин (email, password)
- `POST /api/registration` — регистрация
- `POST /api/refresh` — обновление токена
- `POST /api/logout` — логаут
- `GET /api/me` — профиль по access token

Пример логина:

```
POST /api/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "password123"
}
```

Ответ:

```
{
  "access_token": "...",
  "refresh_token": "...",
  "token_type": "Bearer",
  "expires_in": 900
}
```

Логика
------

[](#логика)

- **Login**: проверяет `password_hash`, выдает access + refresh токены.
- **Refresh**: хранит хэш refresh-токена в `refresh_tokens`, отзывает старый при обновлении.
- **Logout**: отзывает все refresh-токены пользователя.
- **Me**: читает `Authorization: Bearer ` и валидирует JWT.

Переменные окружения
--------------------

[](#переменные-окружения)

- `JWT_SECRET` — ключ подписи JWT.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance74

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Every ~0 days

Total

2

Last Release

147d ago

### Community

Maintainers

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

---

Top Contributors

[![DimsHewiks](https://avatars.githubusercontent.com/u/143056381?v=4)](https://github.com/DimsHewiks "DimsHewiks (2 commits)")

### Embed Badge

![Health badge](/badges/sonata-jwt-auth/health.svg)

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k294.2M219](/packages/google-auth)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

25310.7M83](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

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

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5181.2M3](/packages/robsontenorio-laravel-keycloak-guard)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[rainlab/user-plugin

User plugin for October CMS

11955.0k15](/packages/rainlab-user-plugin)

PHPackages © 2026

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