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

ActiveLibrary

strongnguyen/jwt-auth-service
=============================

Jwt auth for service

014PHP

Since Jan 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/strongnguyen29/JwtAuthService)[ Packagist](https://packagist.org/packages/strongnguyen/jwt-auth-service)[ RSS](/packages/strongnguyen-jwt-auth-service/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Hợp Long JWT Authentication Service
===================================

[](#hợp-long-jwt-authentication-service)

Quản lý xác thực nội bộ giữa các service

---

Cấu hình
--------

[](#cấu-hình)

```
    # .env

    # Secret key validate admin jwt
    JWT_ADMIN_SECRET_KEY=

    # Secret key validate customer jwt
    JWT_CUSTOMER_SECRET_KEY=
```

---

Api Middleware
--------------

[](#api-middleware)

Thêm middleware vào $routeMiddleware trong Kernel.php

```
    // Kernel.php
    $routeMiddleware = [
        'auth.jwt' => \StrongNguyen\JwtAuthService\Http\Middleware\JwtAuthMiddleware::class
    ];
```

Sử dụng trong route

```
    // route/api.php
    Route::middleware('auth.jwt:admin'); // for backend admin
    Route::middleware('auth.jwt:customer'); // for user
```

---

Truy xuất thông tin JWT claim
-----------------------------

[](#truy-xuất-thông-tin-jwt-claim)

#### Admin

[](#admin)

```
    (bool) JwtCustomer::isValid(); // Kiểm tra token tồn tại và có hợp lệ ko
    (array) JwtCustomer::getData(); // Lấy toàn bộ thông tin jwt payload
    (string) JwtCustomer::getFrom(); // Lấy thông tin service gửi
    (string) JwtCustomer::getAppCode(); // Lấy thông tin mã ứng dụng đang yêu cầu
    (int) JwtCustomer::getUserId(); // Lấy thông tin user ID
    (string) JwtCustomer::getUsername(); // Lấy thông tin username
    (string) JwtCustomer::createAdminToken(); // Tạo token test cho admin
```

#### Customer

[](#customer)

```
    (bool) JwtAdmin::isValid(); // Kiểm tra token tồn tại và có hợp lệ ko
    (array) JwtAdmin::getData(); // Lấy toàn bộ thông tin jwt payload
    (string) JwtAdmin::getFrom(); // Lấy thông tin service gửi
    (string) JwtAdmin::getAppCode(); // Lấy thông tin mã ứng dụng đang yêu cầu
    (int) JwtAdmin::getUserId(); // Lấy thông tin user ID
    (string) JwtAdmin::getGroupCode(); // Lấy mã nhóm khách hàng
    (string) JwtAdmin::getCompanyCode(); // Lấy mã khách hàng
    (int) JwtAdmin::getUserCoefficient(); // Lấy hệ số giá hiển thị của user
    (string) JwtAdmin::createCustomerToken(); // Tạo token test cho khách hàng, default: 100
```

###  Health Score

16

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

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/4862912e4eece3b87a40cee32916bc08a58cd3cc2b1910222b457b9d1949348e?d=identicon)[strongnguyen29](/maintainers/strongnguyen29)

---

Top Contributors

[![strongnguyen29](https://avatars.githubusercontent.com/u/44337189?v=4)](https://github.com/strongnguyen29 "strongnguyen29 (16 commits)")

### Embed Badge

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

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

PHPackages © 2026

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