Search by

sailantis / azera-auth

lumielis

Authentication companion for the Azera framework: guards (session, token, JWT, OAuth2), user providers, password reset, email verification, authorization, and two-factor authentication.

Package info

github.com/sailantis/azera-auth

pkg:composer/sailantis/azera-auth

Statistics

Installs: 1

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v0.4.2 2026-11-16 00:04 UTC

This package is auto-updated.

Last update: 2026-11-16 00:19:45 UTC


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 — the AuthManagerInterface implementation; 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: Authorizable trait + 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.