Daycry Auth Documentationยถ
Welcome to the complete documentation for Daycry Auth, a comprehensive authentication and authorization library for CodeIgniter 4.
Getting Started
- Quick Start Guide
- โ๏ธ Configuration Reference
- The Configuration Files
- Database
- Authenticators
- Session Authenticator
- User Settings
- Password Settings
- Password Reset
- Per-User Account Lockout
- Magic Links
- Access Tokens
- JWT Refresh Tokens
- Logging & Monitoring
- Authorization Cache
- Performance: Hot-Path Write Throttles
- Views
- Redirects
- Routes
- Post-Authentication Actions
- Field Validation Rules
- OAuth Providers
- Sessions
- Trusted Devices (2FA bypass)
- WebAuthn / Passkeys
- Password Confirmation (โsudo modeโ)
- Compliance & Observability
- Scheduled Maintenance (
auth:purge) - Common Presets
- Dynamic Configuration
Authentication
- ๐ Authentication โ Complete Guide
- ๐ Index
- The
auth()Facade - Session Authenticator
- Remember Me โ Expiry & Theft Detection
- Per-User Account Lockout
- Compromised-Password Recheck on Login
- Login-Attempt Log & Token Fingerprints
- Access Token Authenticator
- JWT Authenticator
- JWT Access-Token Revocation
- JWT Refresh Tokens
- Magic Link Authentication
- WebAuthn / Passkeys
- Guest Authenticator
- Password Reset
- Force Password Reset
- Pre-Authentication Events
- Switching Between Authenticators
- Custom Authenticators
- Why HTTP Digest Auth is not supported
- OAuth 2.0 & Social Login
- Table of Contents
- How It Works
- Architecture
- Installation
- Configuration
- Routing
- Adding Login Buttons
- Provider Examples
- Account Linking & Email Verification
- Explicit Linking for Logged-In Users
- Stored Token Data
- Profile Fields
- Scopes Granted
- Refresh Tokens
- OAuth Events
- OAuthTokenRepository
- IdentityType Helper
- Unlinking a Provider
- Account Linking Strategy
- Testing OAuth
- ๐ TOTP Two-Factor Authentication
- ๐ WebAuthn / Passkeys
- ๐ฑ Device Sessions
- ๐ Table of Contents
- How It Works
- Configuration
- Database Migration
- Revocation Invalidates the Live Session
- Viewing Active Sessions
- Terminating Sessions
- Concurrent Session Limit
- Trusted Devices (2FA bypass)
- Login Activity Feed
- UserSecurityController Integration
- Building a Sessions Management Page
- New Device Login Notification
- Admin CLI
- Testing Device Sessions
- Security Tips
Controllers & Filters
Authorization & Logging
Compliance & Operations
- ๐ก๏ธ Audit Log & Compliance
- ๐ Index
- Audit Log
- Token Fingerprints in the Login Log
- Hashed-at-Rest Tokens (Magic Link & Password Reset)
- Suspicious Login Detection
- Remember-Me Theft Detection
- JWT Access-Token Revocation (
token_version) - Refresh-Token Revoke Reasons
- Compromised-Password Recheck on Login
- Password History (No Reuse)
- Password Rotation Policy
- GDPR Export & Anonymization
- Scheduled Cleanup (
auth:purge) - Quick Configuration Reference
- ๐ฅ๏ธ CLI Commands
Testing & Reference
- ๐งช Testing Guide
- ๐ Table of Contents
- ๐โโ๏ธ Quick Start
- ๐งช Test Categories
- ๐ง Test Setup
- ๐ก๏ธ Testing Authentication
- ๐ฅ Testing Authorization
- ๐๏ธ Testing Controllers
- ๐ Testing Filters
- ๐ Testing Models
- ๐๏ธ Testing Traits
- ๐ Testing WebAuthn
- ๐ฏ Testing Best Practices
- ๐ Contributing Tests
- ๐ Related Documentation
- ๐ Migration Guide
Main Featuresยถ
Authenticationยถ
Multiple Authenticators: Session, Access Token (with scope enforcement), JWT (with refresh tokens), Magic Link
JWT Access-Token Revocation:
users.token_versionlets you invalidate every outstanding access token at once โUser::revokeIssuedTokens()(โlog out everywhereโ), fired automatically on ban and password change (JWT)TOTP Two-Factor Authentication with backup codes, optional โTrust this deviceโ bypass, brute-force lockout, and single-use (anti-replay) codes (TOTP)
WebAuthn / Passkeys โ passwordless login (usernameless/discoverable) and passkey 2FA, phishing-resistant, opt-in per user behind a global availability flag (WebAuthn)
Device Session Tracking with optional concurrent-session limit and real, enforced revocation โ a revoked session is forced to re-authenticate on the next request (Device Sessions)
Password Reset + Force Password Reset + optional rotation policy + history (no reuse), with hashed-at-rest magic-link & reset tokens
OAuth 2.0 / Social Login: Google, GitHub, Facebook, Microsoft Azure, custom profile fields, OAuth events, explicit account linking (
oauth/link/(:segment)) and verified-email merge safety (OAuth)
Securityยถ
Per-User Account Lockout (atomic) โ independent of IP-based blocking, now also applied to TOTP / backup-code verification
Compromised-Password Recheck on Login (HIBP integration, opt-in)
Suspicious Login Detection with
suspicious-loginevent for email alerts, plus remember-me theft detection (a mismatched validator purges all of the userโs tokens and firesremember-me-theft)Secret-safe login log โ Access Token / JWT credentials are stored in
auth_loginsas a non-reversible SHA-256 fingerprint, never the raw bearer tokenTiming-safe OAuth state validation
Compliance & Operationsยถ
Granular audit log (
auth_audit_logs) โ 22 canonical event types, filterable CLIGDPR helpers โ JSON data export + account anonymization
Admin CLI:
auth:tokens revoke,auth:sessions terminate,auth:totp reset,auth:audit,auth:gdpr export|anonymizeScheduled Maintenance:
auth:purge [--days <n>]โ purges expired remember-me tokens and old terminated device sessions; run on a schedule instead of the probabilistic on-login purge (CLI Commands)Complete Logging: CI4 Events + database login attempts + audit log
Highly Customizable: Extend or replace any component
Quick Startยถ
composer require daycry/auth
php spark migrate --all
php spark auth:setup
// Login
$result = auth()->attempt(['email' => 'user@example.com', 'password' => 'secret']);
if ($result->isOK()) {
return redirect()->to('/dashboard');
}
Documentation Sectionsยถ
Quick Start Guideยถ
Install and configure Daycry Auth in minutes.
Configurationยถ
Every configuration option explained with examples.
Authenticationยถ
Session, Access Token, JWT (with refresh), Magic Link, Password Reset, and more.
TOTP Two-Factor Authenticationยถ
Time-based OTP with authenticator apps, brute-force lockout, and single-use anti-replay codes.
Device Sessionsยถ
Track and manage active logins across devices, with enforced revocation that forces re-authentication.
Security Filtersยถ
Protect routes with authentication and authorization filters, including per-route rate limits (rates:<limit>,<period>) and sudo mode (password-confirm:<seconds>).
Controllersยถ
All included controllers: Login, Register, Password Reset, Force Reset, JWT, UserSecurity.
Authorizationยถ
Groups, permissions, permission cache, wildcard matching, the Gate โ RBAC bridge, and RBAC patterns.
Logging & Monitoringยถ
CI4 Events, database logs, per-user lockout, and rate limiting.
Testingยถ
Unit and integration testing with authentication mocking.
Additional Resourcesยถ
GitHub: daycry/auth
CodeIgniter 4 Docs: codeigniter4.github.io
Packagist: packagist.org/packages/daycry/auth
Issues: github.com/daycry/auth/issues