Download the PHP package sirix/mezzio-authentication without Composer

On this page you can find all versions of the php package sirix/mezzio-authentication. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mezzio-authentication

Mezzio Authentication

Token-based authentication package for Mezzio framework with optional attribute support.

Stability

The 1.x line treats the public contracts, middleware behavior, and request attribute names documented below as stable integration points.

Installation

Package is auto-registered via extra.laminas.config-provider.

Quick Start

1. Configuration

Add to config/autoload/authentication.global.php:

2. Session Setup (for SessionTokenStorage)

Register Mezzio\Session\SessionMiddleware in your pipeline before authentication middleware.

Also configure a session persistence adapter for your application (for example cookie-based or cache-backed persistence), per mezzio/mezzio-session documentation.

If mezzio/mezzio-session is not installed, SessionTokenStorage is not wired and the package uses NullTokenStorage as fallback.

If a token id is provided by transport but current storage backend is unavailable for that request (for example missing session in request), authentication middleware treats request as guest instead of failing with a storage runtime exception.

3. Protect Routes

Manual middleware registration:

With sirix/mezzio-routing-attributes (optional):

Core Concepts

AuthManager

Main HTTP-facing entry point for authentication operations. Current request authentication state is read from the provided ServerRequestInterface; it is not stored in a mutable singleton service.

For HTTP handlers and middleware, prefer AuthManagerInterface::actor($request) or the documented request attributes. Do not resolve a "current user" singleton from the container for per-request authorization.

Token Storage

Two built-in storage backends:

When mezzio/mezzio-session is unavailable, only NullTokenStorage is active.

Custom storage implements TokenStorageInterface.

Token Transport

Extracts token ID from requests:

Custom transport implements TokenTransportInterface.

Actors

Actors represent the authenticated user:

SecurityActorProviderInterface is intended for non-request or application-managed security contexts. Its default ContextActorProvider reads from the injected AuthContextInterface service and is not automatically synchronized with the current HTTP request. It is not a replacement for AuthManagerInterface::actor($request) in HTTP code.

Middleware

Middleware Behavior
AuthenticateMiddleware Requires authentication, throws Exception\AuthenticationException (401)
OptionalAuthenticateMiddleware Attempts authentication, passes through regardless
GuestOnlyMiddleware Allows only guests, throws Exception\AlreadyAuthenticatedException (403)

Attributes

Attribute Middleware Added
#[Authenticated] AuthenticateMiddleware
#[GuestOnly] OptionalAuthenticateMiddleware + GuestOnlyMiddleware

When sirix/mezzio-routing-attributes is installed, attributes auto-inject middleware. Without it, middleware must be registered manually.

Request Attributes

After AuthenticateMiddleware or OptionalAuthenticateMiddleware processes a request, these stable attributes are available:

Stable attribute names:

These attributes are the package's current-request state boundary and are safe for long-running workers because they live on the PSR-7 request instance.

RBAC Integration

sirix/mezzio-rbac can authorize the current request by reading the actor from:

The authentication package does not depend on RBAC. The integration contract is structural: the actor exposes getRoles(): array.

SessionTokenStorage reads session from request attributes in this order:

  1. Mezzio\Session\SessionInterface::class
  2. 'session'

When using session storage, Mezzio\Session\SessionMiddleware must run before authentication middleware.

For cookie transport in production, use secure: true over HTTPS, keep http_only: true, and choose a same_site policy appropriate for your application flow.

Extensibility

Custom Actor Provider

Register in your dependencies:

Custom Token Storage

Custom Transport

Exceptions

Exception Purpose
Exception\AuthenticationException 401 Unauthorized response
Exception\AlreadyAuthenticatedException 403 Forbidden response
Exception\StorageException Token storage failure
Sirix\ContainerResolver\Exception\MissingContainerServiceException Required container service is not registered while a factory builds an object
Sirix\ContainerResolver\Exception\InvalidContainerServiceException Container service has an unexpected type
Sirix\ContainerResolver\Exception\InvalidConfigValueException Factory configuration value has an unexpected type or unsupported value

HTTP exceptions provide getStatusCode(), getHeaders(), and getPublicMessage() for integration with error handling middleware. Factory configuration errors are reported by sirix/container-resolver exceptions.

Design Notes

The package depends on contracts, not on concrete persistence. Built-in implementations cover common use cases, but everything is replaceable via PSR-11 service configuration.


All versions of mezzio-authentication with dependencies

PHP Build Version
Package Version
Requires php Version ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0
psr/container Version ^1.0 || ^2.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
sirix/container-resolver Version ^0.2 || ^1.0
sirix/mezzio-routing-contracts Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sirix/mezzio-authentication contains the following files

Loading the files please wait ...