sailantis / azera-auth
Authentication companion for the Azera framework: guards (session, token, JWT, OAuth2), user providers, password reset, email verification, authorization, and two-factor authentication.
v0.4.2
2026-11-16 00:04 UTC
Requires
- php: >=8.2
- psr/event-dispatcher: ^1.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
- sailantis/azera-framework: ^0.4.1 || dev-main
Requires (Dev)
- phpunit/phpunit: ^10.5
Suggests
- bacon/bacon-qr-code: For TwoFactorAuthenticator QR code rendering.
- firebase/php-jwt: For the JwtGuard (HS256/RS256 token authentication).
- league/oauth2-client: For the OAuth2Guard (Google, GitHub, generic providers).
- spomky-labs/otphp: For TwoFactorAuthenticator (TOTP).
Provides
None
Conflicts
None
Replaces
None
README
Authentication companion for the Azera framework.
The framework ships authentication contracts (Azera\Security\AuthManagerInterface, Azera\Security\GuardInterface) plus primitives (Hasher, RateLimiter, CsrfMiddleware). This package provides the implementations the docs defer to the companion:
Azera\Auth\AuthManager— theAuthManagerInterfaceimplementation; a named-guard registry with current-guard tracking.- Guards:
SessionGuard,TokenGuard,JwtGuard(optional),OAuth2Guard(optional). - User providers:
UserProviderInterface+DbUserProvider— decouples guards from how users are loaded. - Middleware:
AuthMiddleware— resolves the current user per request, 401s when auth is required. - Password reset:
PasswordBroker+DbTokenRepository. - Email verification:
EmailVerification. - Authorization:
Authorizabletrait +Gate(roles & abilities). - Two-factor:
TwoFactorAuthenticator(TOTP + QR + backup codes; extracted from the Sailantis homepage). - Events: PSR-14
Attempting,Authenticated,Login,Failed,Lockout,Logout,PasswordResetRequested,Verified.
Installation
composer require sailantis/azera-auth
Optional features pull their dependencies via Composer suggest:
| Feature | Suggested package |
|---|---|
JwtGuard |
firebase/php-jwt |
OAuth2Guard |
league/oauth2-client |
TwoFactorAuthenticator (TOTP) |
spomky-labs/otphp |
TwoFactorAuthenticator (QR) |
bacon/bacon-qr-code |
Wiring
use Azera\Auth\AuthManager; use Azera\Auth\Guard\SessionGuard; use Azera\Auth\Guard\SessionGuardConfig; use Azera\Auth\Provider\DbUserProvider; use Azera\Security\AuthManagerInterface; use Azera\Security\Hasher; $manager = new AuthManager(); $manager->addGuard('web', new SessionGuard( provider: new DbUserProvider(/* ... */), session: $ctx->session(), hasher: new Hasher(), config: new SessionGuardConfig( rateLimiter: $ctx->get(RateLimiter::class), cookies: $ctx->cookies(), ), )); $ctx->set(AuthManagerInterface::class, $manager);
See the plan and each class for details.
License
MIT.