session->get(ClientFlowLoginV2Controller::EPHEMERAL_NAME); // Not an ephemeral session. if ($sessionCreationTime === null) { return; } // Lax enforcement until TTL is reached. if ($this->timeFactory->getTime() < $sessionCreationTime + self::EPHEMERAL_SESSION_TTL) { return; } // Allow certain controllers/methods to proceed without logging out. if ( $controller instanceof ClientFlowLoginV2Controller && ($methodName === 'grantPage' || $methodName === 'generateAppPassword') ) { return; } if ($controller instanceof TwoFactorChallengeController || $controller instanceof ALoginSetupController) { return; } if ($this->reflector->hasAnnotationOrAttribute('PublicPage', PublicPage::class)) { return; } $this->logger->info('Closing user and PHP session for ephemeral session', [ 'controller' => $controller::class, 'method' => $methodName, ]); $this->userSession->logout(); $this->session->close(); } }