/** * {@inheritdoc} */ public function applyTo(ServerRequestInterface $request, ResponseInterface $response, TransportInterface $transport) { if ($transport instanceof AuthenticationTransportInterface || $transport instanceof AuthorizationTransportInterface) { $request = $request->withAttribute('authentication_adapter', $this)->withAttribute('authenticated_user', $transport->getAuthenticatedUser())->withAttribute('authenticated_with', $transport->getAuthenticatedWith()); } return [$request, $response]; }
/** * {@inheritdoc} */ public function applyTo(ServerRequestInterface $request, ResponseInterface $response, TransportInterface $transport) { // Extend session if ($transport instanceof AuthenticationTransportInterface) { $authenticated_with = $transport->getAuthenticatedWith(); if (!$authenticated_with instanceof SessionInterface) { throw new InvalidArgumentException('Only user sessions are supported'); } $authenticated_with->extendSession(); list($request, $response) = $this->cookies->set($request, $response, $this->session_cookie_name, $authenticated_with->getSessionId(), ['ttl' => $authenticated_with->getSessionTtl(), 'http_only' => true]); // Log in } elseif ($transport instanceof AuthorizationTransportInterface) { $authenticated_with = $transport->getAuthenticatedWith(); if (!$authenticated_with instanceof SessionInterface) { throw new InvalidArgumentException('Only user sessions are supported'); } list($request, $response) = $this->cookies->set($request, $response, $this->session_cookie_name, $authenticated_with->getSessionId(), ['ttl' => $authenticated_with->getSessionTtl(), 'http_only' => true]); // Log out or clean-up } elseif ($transport instanceof DeauthenticationTransportInterface || $transport instanceof CleanUpTransportInterface) { list($request, $response) = $this->cookies->remove($request, $response, $this->session_cookie_name); } return parent::applyTo($request, $response, $transport); }