/** * Redirects to defined action by new users. * * Note: appendExceedingArguments is requered in your routes. * * @return void */ protected function makeRedirectByDetectingNewUser() { $providerName = $this->request->getInternalArgument('__casAuthenticationProviderName'); if (empty($providerName)) { throw new \TYPO3\Flow\Security\Exception('New user detected but can not provide redirect to defined action, because requered argument "__casAuthenticationProviderName" is not set.', 1375272628); } if (!$this->casManager->isCasProvider($providerName)) { throw new \RafaelKa\JasigPhpCas\Exception\InvalidArgumentException(sprintf('New user detected but can not provide redirect to defined action, because "%s" provider is not of type "%s".', $providerName, \RafaelKa\JasigPhpCas\Service\CasManager::DEFAULT_CAS_PROVIDER), 1375273096); } $redirectByNewUser = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow.security.authentication.providers.' . $providerName . '.providerOptions.Mapping.redirectByNewUser'); if (empty($redirectByNewUser['@action'])) { throw new \RafaelKa\JasigPhpCas\Exception\InvalidArgumentException(sprintf('')); } if (empty($redirectByNewUser['@controller'])) { $controllerName = null; } else { $controllerName = $redirectByNewUser['@controller']; } if (empty($redirectByNewUser['@package'])) { $packageKey = null; } elseif (!empty($redirectByNewUser['@subpackage'])) { $packageKey = $redirectByNewUser['@package'] . '\\' . $redirectByNewUser['@subpackage']; } else { $packageKey = $redirectByNewUser['@package']; } if (empty($redirectByNewUser['@arguments'])) { $arguments = ['providerName' => $providerName]; } else { $arguments = ArraysUtility::arrayMergeRecursiveOverrule(['providerName' => $providerName], $redirectByNewUser['@arguments']); } if (empty($redirectByNewUser['@delay'])) { $delay = null; } else { $delay = $redirectByNewUser['@delay']; } if (empty($redirectByNewUser['@statusCode'])) { $statusCode = 303; } else { $statusCode = $redirectByNewUser['@statusCode']; } if (empty($redirectByNewUser['@format'])) { $format = null; } else { $format = $redirectByNewUser['@format']; } $this->redirect($redirectByNewUser['@action'], $controllerName, $packageKey, $arguments, $delay, $statusCode, $format); }
/** * Returns the class names of the tokens this provider can authenticate. * * @return array */ public function getTokenClassNames() { return $this->casManager->getTokenClassNamesByProviderName($this->name); }
/** * If Action for new users is defined and new user is detected, then makes this method redirect to defined Action and breaks authentication. * * You must persist new user self and afterwards authenticate this user by calling $this->casManager->authenticateNewUser($providerName). * * @param string $providerName * @param Account $account * * @throws StopActionException * * @return void */ private function mekeRedirectByNewUserIfNeeded($providerName, Account $account) { $redirectControllerAndAction = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow.security.authentication.providers.' . $providerName . '.providerOptions.Mapping.redirectByNewUser'); if (!empty($redirectControllerAndAction)) { $this->casManager->setMiscellaneousByPath($providerName . '.Account', $account); $this->fixWhiteScreenByAbortingAuthentication($providerName); throw new StopActionException('New user detectded.', 1375270925); } }