Reference

Authentication adapters

The authentication adapters for zend-expressive-authentication implement the interface Zend\Expressive\Authentication\AuthenticationInterface:

namespace Zend\Expressive\Authentication;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;

interface AuthenticationInterface
{
    /**
     * Authenticate the PSR-7 request and return a valid user,
     * or null if not authenticated
     *
     * @param ServerRequestInterface $request
     * @return UserInterface|null
     */
    public function authenticate(ServerRequestInterface $request): ?UserInterface;

    /**
     * Generate the unauthorized response
     *
     * @param ServerRequestInterface $request
     * @return ResponseInterface
     */
    public function unauthorizedResponse(ServerRequestInterface $request): ResponseInterface;
}

This interface contains two method: authenticate() to check if a PSR-7 request contains a valid credential, and unauthorizedResponse() to generate and return an unauthorized response.

We provide 4 authentication adapters:

Found a mistake or want to contribute to the documentation? Edit this page on GitHub!