PHPackages                             monkeyscloud/monkeyslegion-auth - 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. monkeyscloud/monkeyslegion-auth

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

monkeyscloud/monkeyslegion-auth
===============================

Comprehensive authentication and authorization package with JWT, RBAC, 2FA, OAuth, and API keys

2.0.1(2mo ago)01.1k↑142.9%2MITPHPPHP ^8.4

Since Jul 23Pushed 2mo agoCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion-Auth)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion-auth)[ RSS](/packages/monkeyscloud-monkeyslegion-auth/feed)WikiDiscussions main Synced 1mo ago

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

MonkeysLegion Auth
==================

[](#monkeyslegion-auth)

[![PHP Version](https://camo.githubusercontent.com/6e44ad49e5307c87d1393389feb52ab61c99956e2e5f8c77177b2501f1d3d47f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![PSR-7](https://camo.githubusercontent.com/1e31c6255577a0f143560a817dd59107a1264660e7e123104b4ad69a36b37d10/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d372d626c75652e737667)](https://www.php-fig.org/psr/psr-7/)[![PSR-15](https://camo.githubusercontent.com/715fe19567469d13f5e8c2a2430501b6853988f14adeee4fb0775821d72c2a08/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d31352d626c75652e737667)](https://www.php-fig.org/psr/psr-15/)

A comprehensive, production-ready PHP authentication and authorization package for modern applications.

---

✨ Features
----------

[](#-features)

FeatureDescription**JWT Authentication**Stateless auth with access/refresh token pairs and automatic rotation**RBAC**Role-based access control with permission inheritance and wildcards**2FA/TOTP**Two-factor authentication compatible with Google Authenticator, Authy, 1Password**OAuth2**Social login with Google, GitHub (easily extensible for more providers)**API Keys**Scoped API keys for machine-to-machine authentication**Rate Limiting**Brute force protection with Redis, cache, or in-memory backends**Token Revocation**Blacklist tokens instantly with Redis or database storage**Policy-Based Auth**Laravel-style policies for fine-grained authorization**Event System**PSR-14 compatible events for audit logging and integrations**Custom Exceptions**Rich exception hierarchy with context for better error handling---

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

[](#-requirements)

- PHP 8.4 or higher
- [firebase/php-jwt](https://github.com/firebase/php-jwt) ^6.10
- PSR-7 HTTP Message implementation (e.g., `nyholm/psr7`)
- PSR-15 HTTP Server Middleware support
- **Optional:** Redis extension for production rate limiting/token storage

---

📦 Installation
--------------

[](#-installation)

```
composer require monkeyscloud/monkeyslegion-auth
```

---

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Basic Authentication Setup

[](#1-basic-authentication-setup)

```
