BackendUserAuthenticator implements MiddlewareInterface
Boilerplate to authenticate a backend user in the current workflow, can be used for TYPO3 Backend and Frontend requests.
The actual authentication and the selection if no-cache headers to responses should be applied should still reside in the "process()" method which should be extended by derivative classes.
In derivative classes, the Context API can be used to detect, if a backend user is logged in like this:
$response = $handler->handle($request); if ($this->context->getAspect('backend.user')->isLoggedIn()) { return $this->applyHeadersToResponse($response); }
this class might get merged again with the subclasses
Table of Contents
Interfaces
- MiddlewareInterface
Properties
Methods
- __construct() : mixed
- process() : ResponseInterface
- applyHeadersToResponse() : ResponseInterface
- Adding headers to the response to avoid caching on the client side.
- setBackendUserAspect() : void
- Register the backend user as aspect
Properties
$context
protected
Context
$context
Methods
__construct()
public
__construct(Context $context) : mixed
Parameters
- $context : Context
process()
public
abstract process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface
Tags
Return values
ResponseInterfaceapplyHeadersToResponse()
Adding headers to the response to avoid caching on the client side.
protected
applyHeadersToResponse(ResponseInterface $response) : ResponseInterface
These headers will override any previous headers of these names sent. Get the http headers to be sent if an authenticated user is available, in order to disallow browsers to store the response on the client side.
Parameters
- $response : ResponseInterface
Return values
ResponseInterface —the modified response object.
setBackendUserAspect()
Register the backend user as aspect
protected
setBackendUserAspect(BackendUserAuthentication|null $user[, int|null $alternativeWorkspaceId = null ]) : void
Parameters
- $user : BackendUserAuthentication|null
- $alternativeWorkspaceId : int|null = null