PHPackages                             darkauth/darkauth - 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. darkauth/darkauth

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

darkauth/darkauth
=================

A flexible, production-grade authentication library for CodeIgniter 3 and PHP 7.4+. Supports Session and JWT drivers.

1.0.0(4w ago)01↓100%MITPHPPHP &gt;=7.4.33CI failing

Since May 11Pushed 4w agoCompare

[ Source](https://github.com/imamrasyid/Darkauth)[ Packagist](https://packagist.org/packages/darkauth/darkauth)[ RSS](/packages/darkauth-darkauth/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

DarkAuth
========

[](#darkauth)

[![Latest Stable Version](https://camo.githubusercontent.com/044095359c82bd967f51c84f5ec3e2529659c9ef645a69e458d8e7f356b17594/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461726b617574682f6461726b617574682e737667)](https://packagist.org/packages/darkauth/darkauth)[![License](https://camo.githubusercontent.com/55453d0a0ab4c0d77275e1f87839b8272a48e6dfbded9210d5d54fb0f76ec14c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6461726b617574682f6461726b617574682e737667)](https://packagist.org/packages/darkauth/darkauth)[![PHP Version](https://camo.githubusercontent.com/70434bc4473fdcb5df74b5c836fd8ce179b755ffb6674fb747854d1e261aecd8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e342e33332d3838393262662e737667)](https://packagist.org/packages/darkauth/darkauth)

**DarkAuth** adalah library autentikasi modern, fleksibel, dan berstandar produksi yang dirancang khusus untuk membawa pola keamanan mutakhir ke aplikasi **CodeIgniter 3** dan lingkungan PHP 7.4+.

---

✨ Fitur Utama
-------------

[](#-fitur-utama)

- 🛡️ **Multi-Driver Architecture**: Switch antara `Session` (Web) dan `JWT` (API) dengan satu API yang seragam.
- 🔐 **Advanced MFA**: Mendukung **TOTP (Google Authenticator)** dan **Recovery Codes** secara native.
- 🤖 **Adaptive Security**: Dilengkapi dengan **Risk Engine** untuk mendeteksi anomali IP/Perangkat dan memicu tantangan keamanan secara otomatis.
- 🧱 **SOLID &amp; Modular**: Arsitektur yang bersih, mudah ditest, dan mengikuti standar PSR-4.
- 📋 **Audit Trail**: Pencatatan log keamanan yang tahan manipulasi (*Tamper-resistant*) dengan tanda tangan digital (HMAC).
- 👴 **Government-Friendly UX**: Template UI yang dirancang khusus untuk pengguna non-teknis/senior dengan instruksi yang jelas.
- ⚡ **Plug-and-Play**: Integrasi mudah ke CodeIgniter 3 tanpa mengubah file core framework.

---

🚀 Instalasi
-----------

[](#-instalasi)

Instalasi melalui Composer:

```
composer require darkauth/darkauth
```

Lalu jalankan skema database yang diperlukan (opsional namun direkomendasikan untuk fitur lanjut):

```
# Lihat file database.sql untuk skema tabel
```

---

⚙️ Konfigurasi Dasar (CI3)
--------------------------

[](#️-konfigurasi-dasar-ci3)

1. Salin file `config/auth.php` ke folder `application/config/` Anda.
2. Load library di controller Anda:

```
$this->load->library(\Darkauth\Support\CI3Auth::class, null, 'darkauth');
```

---

📖 Panduan Penggunaan
--------------------

[](#-panduan-penggunaan)

### 1. Autentikasi Dasar (Web)

[](#1-autentikasi-dasar-web)

```
// Login user
if ($this->darkauth->attempt(['username' => 'admin', 'password' => 'rahasia'])) {
    redirect('dashboard');
}

// Cek status
if ($this->darkauth->check()) {
    $user = $this->darkauth->user();
    echo "Halo, " . $user->username;
}

// Logout
$this->darkauth->logout();
```

### 2. Autentikasi API (JWT)

[](#2-autentikasi-api-jwt)

```
// Mengambil guard API
$guard = $this->darkauth->guard('api');

// Issue Token
$token = $guard->issueToken($user);

// Verifikasi (Otomatis membaca header Authorization: Bearer ...)
if ($guard->check()) {
    return $guard->user();
}
```

### 3. Implementasi MFA (TOTP)

[](#3-implementasi-mfa-totp)

```
$mfa = $this->darkauth->mfa();

// Buat Secret Baru (Saat pendaftaran MFA)
$secret = $mfa->generateSecret();
$qrUrl = $mfa->getQrCodeUrl('user@email.com', $secret, 'NamaSistem');

// Verifikasi Kode dari HP
if ($mfa->verify($secret, $this->input->post('otp_code'))) {
    echo "MFA Berhasil!";
}
```

### 4. Adaptive Security (Risk-Based Auth)

[](#4-adaptive-security-risk-based-auth)

DarkAuth dapat mendeteksi risiko secara otomatis untuk memicu tantangan tambahan:

```
$riskScore = $this->darkauth->getRiskEngine()->calculateScore($user, [
    'ip' => $this->input->ip_address(),
    'ua' => $this->input->user_agent()
]);

if ($riskScore > 70) {
    // Paksa Captcha atau MFA karena ada kecurigaan
    $this->session->set_userdata('require_mfa', true);
}
```

### 5. Audit Logging

[](#5-audit-logging)

Setiap kejadian penting dicatat otomatis jika Anda mengaktifkan listener:

```
$this->darkauth->events()->listen('auth.login.failed', function($payload) {
    // Logika kustom saat login gagal (misal: kirim email peringatan)
});
```

---

📁 Struktur Proyek
-----------------

[](#-struktur-proyek)

- `src/Core`: Interface dan kontrak dasar.
- `src/Drivers`: Implementasi Session dan JWT.
- `src/MFA`: Logika TOTP dan Recovery Codes.
- `src/Security`: Risk Engine, Rate Limiter, dan Trusted Devices.
- `src/Audit`: Sistem Audit Log tamper-resistant.
- `src/Support/UI`: Template HTML/CSS ramah pengguna senior.

---

📄 Lisensi
---------

[](#-lisensi)

Proyek ini dilisensikan di bawah **MIT License**. Silakan gunakan secara bebas untuk proyek komersial maupun personal.

---

**Dibuat dengan ❤️ untuk ekosistem PHP Indonesia.**

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance94

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

29d ago

### Community

Maintainers

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

---

Top Contributors

[![imamrasyid](https://avatars.githubusercontent.com/u/64980773?v=4)](https://github.com/imamrasyid "imamrasyid (8 commits)")

---

Tags

phpjwtauthAuthenticationsessioncodeigniter3darkauth

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/darkauth-darkauth/health.svg)

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

###  Alternatives

[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2280.2k3](/packages/kinde-oss-kinde-auth-php)[maicol07/flarum-ext-sso

SSO for Flarum

468.7k](/packages/maicol07-flarum-ext-sso)[benbjurstrom/cognito-jwt-guard

A laravel auth guard for JSON Web Tokens issued by Amazon AWS Cognito

1113.1k](/packages/benbjurstrom-cognito-jwt-guard)[swoft/auth

Auth component for swoft

127.2k1](/packages/swoft-auth)

PHPackages © 2026

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