Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Authentication Laravel Package

zendframework/zend-authentication

Zend\Authentication provides a flexible authentication API with adapters for common scenarios. This repository was abandoned on 2019-12-31 and has moved to laminas/laminas-authentication. Documentation: docs.zendframework.com/zend-authentication.

View on GitHub
Deep Wiki
Context7

Getting Started

  • This package is part of the archived Zend Framework (ZF) ecosystem; it's effectively legacy. While functional, modern Laravel applications should prefer Laravel’s built-in Auth system or Symfony’s Security component.
  • PHP 7.3+ requirement: Ensure your project uses PHP 7.3+ (removed support for older versions).
  • If maintaining a legacy ZF/Laminas app: install via Composer (composer require zendframework/zend-authentication:^2.7.0), then configure adapters (e.g., DbTable, Ldap, OAuth2) in config/autoload/auth.local.php (ZF style) or service manager.
  • First use case: authenticating users against a database via Zend\Authentication\Adapter\DbTable. Example: create a class implementing AdapterInterface, call $authentication->authenticate($adapter).
  • Basic Auth re-challenge: Updated behavior for Basic scheme authentication now re-challenges clients if credentials in the Authorization header cannot be base64 decoded (PR #42).

Implementation Patterns

  • Adapter-centric workflow: Implement custom adapters by adhering to AdapterInterface and returning Result objects with status, identity, and messages.
  • Storage abstraction: Use Zend\Authentication\Storage (e.g., Session) to persist identity post-authentication — inject into service layer for manual authentication ($auth->authenticate()$auth->getStorage()->write($result->getIdentity())).
  • Laminas Integration: If migrating to Laminas (the spiritual successor), replace zendframework/ with laminas/ namespaces (laminas/laminas-authentication). Service configuration moves to config/services.php or Module::getServiceConfig().
  • DI & Service Layer: Register authenticator service (e.g., AuthService) using ServiceFactory, injecting storage + adapter — avoid direct calls to Zend\Authentication\AuthenticationService in controllers.
  • Custom validation messages: Leverage the new Zend\Authentication\Validator\Authentication configuration option to map custom authentication result codes to validation messages (PR #47). Example:
    $validator = new AuthenticationValidator([
        'customCodes' => [
            'invalid_credentials' => 'Invalid username or password.',
            'account_locked' => 'Your account is temporarily locked.',
        ],
    ]);
    
  • Basic Auth handling: For HTTP Basic Auth, ensure client-side handling accounts for re-challenge behavior when credentials are malformed.

Gotchas and Tips

  • No active maintenance: Since ZF is archived (2020), use only in legacy apps. New projects should adopt laravel/ui, laravel/breeze, or Symfony’s security stack.
  • Class namespace drift: If upgrading from ZF2 → Laminas, Zend\* classes are migrated to Laminas\*. Replace use Zend\Authentication\...use Laminas\Authentication\....
  • Session storage quirk: Laravel’s session is driver-agnostic, but Zend\Authentication\Storage\Session uses its own session handler — ensure compatible session start and namespace isolation to avoid collisions.
  • Result inspection: Always check getResult()->isValid(), and review getMessages() for user-facing feedback — failed authentications return opaque errors without explicit logging.
  • Extensibility: Extend DbTable adapter for multi-tenant auth (e.g., dynamic table names) or add custom credentials hashing by wrapping the adapter in a decorator that pre-processes credentials.
  • PHP 7.3+ requirement: Ensure your project’s composer.json enforces PHP 7.3+ compatibility. Older versions are no longer supported (removed zend-stdlib v2 compatibility in PR #44).
  • Basic Auth re-challenge: If implementing Basic Auth, account for the new re-challenge behavior. Clients must handle 401 Unauthorized responses with a WWW-Authenticate: Basic header and retry with valid credentials.
  • Custom validation messages: Use the new validator configuration to provide granular control over error messages, improving UX for edge cases (e.g., locked accounts, rate limits).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport