PHPackages                             bpjs/auth-client - 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. bpjs/auth-client

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

bpjs/auth-client
================

Shared auth client for all apps

1.0.0(2mo ago)04MITPHPPHP &gt;=8.0

Since May 14Pushed 2mo agoCompare

[ Source](https://github.com/crashmyname/bpjs-auth-client)[ Packagist](https://packagist.org/packages/bpjs/auth-client)[ RSS](/packages/bpjs-auth-client/feed)WikiDiscussions main Synced 1w ago

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

🔐 Auth Service Client
=====================

[](#-auth-service-client)

Library autentikasi terpusat untuk microservices BPJS. Cukup install, tambah 1 baris middleware, beres!

[![PHP Version](https://camo.githubusercontent.com/1a5e13126d38c1d05f712dae30e7f60ae0444a9c882e9e526349ccba27facb8d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e312d626c7565)](https://php.net)![Tests](https://camo.githubusercontent.com/7c8d38a14cf8aedae1daeaa3df1c60991d581b3b1deee99b031439c5d5bda1e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54657374732d3332253230504153532d677265656e)![License](https://camo.githubusercontent.com/8174925d009b42074d50ab5cc7e29fcb1aa613b0d9cb2e43097697a40cf90fa4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f77)

---

📖 Daftar Isi
------------

[](#-daftar-isi)

- [Konsep](#-konsep)
- [Requirements](#-requirements)
- [Installasi](#-installasi)
- [Quick Start](#-quick-start)
- [Cara Kerja](#-cara-kerja)
- [Konfigurasi](#-konfigurasi)
- [Penggunaan](#-penggunaan)
- [API Reference](#-api-reference)
- [Error Handling](#-error-handling)
- [Testing](#-testing)
- [Troubleshooting](#-troubleshooting)

---

💡 Konsep
--------

[](#-konsep)

┌─────────────┐ │ User Service │ ← Satu-satunya tempat login &amp; database user │ :8000 │ └──────┬───────┘ │ │ Token diverifikasi ke sini │ ┌──────┴──────────────────────────┐ │ │ │ ┌──────────┐ ┌──────────┐ │ │ │ HRM │ │ Ticket │ │ ← Service lain TIDAK perlu │ │ :8001 │ │ :8002 │ │ database user sendiri │ └──────────┘ └──────────┘ │ │ │ │ User login SEKALI, │ │ bisa akses SEMUA service │ └──────────────────────────────────┘

**Keuntungan:**

- ✅ Single Sign-On (SSO) - login sekali akses semua
- ✅ Tidak perlu database user di setiap service
- ✅ Tidak perlu sharing JWT secret key
- ✅ User management terpusat
- ✅ Logout di User Service langsung berpengaruh ke semua service

---

📋 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- ext-curl
- ext-json
- Composer

---

🚀 Installasi
------------

[](#-installasi)

### 1. via composer

[](#1-via-composer)

```
composer require bpjs/auth-client

# .env di setiap aplikasi
AUTH_SERVICE_URL=http://192.168.1.10:8000
AUTH_APP_KEY=your_app_key
AUTH_APP_SECRET=your_app_secret
```

```
