PHPackages                             irsadarief/jkd-sso - 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. irsadarief/jkd-sso

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

irsadarief/jkd-sso
==================

BPS Single Sign On Client For PHP

1.8.0(1y ago)22.6k↓50%3[1 PRs](https://github.com/irsadarief/jkd-sso/pulls)GPL-3.0-onlyPHPCI failing

Since Jan 9Pushed 1y ago2 watchersCompare

[ Source](https://github.com/irsadarief/jkd-sso)[ Packagist](https://packagist.org/packages/irsadarief/jkd-sso)[ RSS](/packages/irsadarief-jkd-sso/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (12)Used By (0)

Badan Pusat Statistik SSO (Single Sign-On)
==========================================

[](#badan-pusat-statistik-sso-single-sign-on)

[![Latest Version](https://camo.githubusercontent.com/84cc75a1eec0593d73b9fe290db3be93b2cd9d80544f8e36bd4f427f3c5e495a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f697273616461726965662f6a6b642d73736f2e7376673f7374796c653d666c61742d737175617265)](https://github.com/irsadarief/jkd-sso/releases)[![Software License](https://camo.githubusercontent.com/53c10a7fa0f9a135ad78f271d0c22a2b2580a91b260c3cd1e6e4125d59cda6bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f697273616461726965662f6a6b642d73736f3f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/c8d1e21755429f0e9125cf012c518e4b4ca8b0815d6bc0296b74dfc043067177/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f697273616461726965662f6a6b642d73736f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/irsadarief/jkd-sso/code-structure)[![Quality Score](https://camo.githubusercontent.com/396a1fdce26fe6372d493683775451d3d1dceb806fb6a4ec580497b02e2e339e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f697273616461726965662f6a6b642d73736f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/irsadarief/jkd-sso)[![Total Downloads](https://camo.githubusercontent.com/48c526fd7e8e21ec6db6ca597bbb8c876b19417b80dcce334d5afb116ad9105d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f697273616461726965662f6a6b642d73736f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/irsadarief/jkd-sso)

Instalasi
---------

[](#instalasi)

Untuk menginstall, anda dapat menggunakan composer:

```
composer require irsadarief/jkd-sso

```

Untuk yang belum menginstall composer, informasi mengenai instalasi dan penggunaan composer dapat diakses [disini](https://github.com/composer/composer).

Penggunaan
----------

[](#penggunaan)

Untuk menggunakan library ini bisa dengan `\JKD\SSO\Client\Provider\Keycloak` sebagai provider.

Untuk `authServerUrl` Anda dapat menuliskan  .

untuk `realm` anda dapat menuliskan `pegawai-bps`

Contoh Kode
-----------

[](#contoh-kode)

```
$provider = new JKD\SSO\Client\Provider\Keycloak([
    'authServerUrl'         => 'https://sso.bps.go.id',
    'realm'                 => 'pegawai-bps',
    'clientId'              => '{client-id}',
    'clientSecret'          => '{client-secret}',
    'redirectUri'           => 'https://example.com/callback-url'
]);

if (!isset($_GET['code'])) {

    // Untuk mendapatkan authorization code
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

// Mengecek state yang disimpan saat ini untuk memitigasi serangan CSRF
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    try {
        $token = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);
    } catch (Exception $e) {
        exit('Gagal mendapatkan akses token : '.$e->getMessage());
    }

    // Opsional: Setelah mendapatkan token, anda dapat melihat data profil pengguna
    try {

        $user = $provider->getResourceOwner($token);
            echo "Nama : ".$user->getName();
            echo "E-Mail : ". $user->getEmail();
            echo "Username : ". $user->getUsername();
            echo "NIP : ". $user->getNip();
            echo "NIP Baru : ". $user->getNipBaru();
            echo "Kode Organisasi : ". $user->getKodeOrganisasi();
            echo "Kode Provinsi : ". $user->getKodeProvinsi();
            echo "Kode Kabupaten : ". $user->getKodeKabupaten();
            echo "Alamat Kantor : ". $user->getAlamatKantor();
            echo "Provinsi : ". $user->getProvinsi();
            echo "Kabupaten : ". $user->getKabupaten();
            echo "Golongan : ". $user->getGolongan();
            echo "Jabatan : ". $user->getJabatan();
            echo "Eselon : ". $user->getEselon();

    } catch (Exception $e) {
        exit('Gagal Mendapatkan Data Pengguna: '.$e->getMessage());
    }

    // Gunakan token ini untuk berinteraksi dengan API di sisi pengguna
    echo $token->getToken();
}
```

Penggunaan API untuk mengakses data pegawai dapat melihat pada [api-pegawai](https://git.bps.go.id/jkd-repo/api-pegawai).

Mendapatkan link Logout
-----------------------

[](#mendapatkan-link-logout)

```
$url_logout = $provider->getLogoutUrl()
```

Memperbarui Token
-----------------

[](#memperbarui-token)

```
$provider = new JKD\SSO\Client\Provider\Keycloak([
    'authServerUrl'         => 'https://sso.bps.go.id',
    'realm'                 => 'pegawai-bps',
    'clientId'              => '{keycloak-client-id}',
    'clientSecret'          => '{keycloak-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

$token = $provider->getAccessToken('refresh_token', ['refresh_token' => $token->getRefreshToken()]);
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance48

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~215 days

Recently: every ~449 days

Total

10

Last Release

380d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20633603?v=4)[Irsad Arief](/maintainers/irsadarief)[@irsadarief](https://github.com/irsadarief)

---

Top Contributors

[![irsadarief](https://avatars.githubusercontent.com/u/20633603?v=4)](https://github.com/irsadarief "irsadarief (22 commits)")

---

Tags

clientSSOoauth2authorizationauthorisationkeycloakbps

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/irsadarief-jkd-sso/health.svg)

```
[![Health](https://phpackages.com/badges/irsadarief-jkd-sso/health.svg)](https://phpackages.com/packages/irsadarief-jkd-sso)
```

###  Alternatives

[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[thenetworg/oauth2-azure

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

2509.6M48](/packages/thenetworg-oauth2-azure)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

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