{"action":"closed","issue":{"url":"https://api.github.com/repos/johannessteu/neos-development-collection/issues/875","repository_url":"https://api.github.com/repos/johannessteu/neos-development-collection","labels_url":"https://api.github.com/repos/johannessteu/neos-development-collection/issues/875/labels{/name}","comments_url":"https://api.github.com/repos/johannessteu/neos-development-collection/issues/875/comments","events_url":"https://api.github.com/repos/johannessteu/neos-development-collection/issues/875/events","html_url":"https://github.com/johannessteu/neos-development-collection/issues/875","id":174036401,"number":875,"title":"Unable to log into backend with provider != Typo3BackendProvider","user":{"login":"johannessteu","id":769789,"avatar_url":"https://avatars.githubusercontent.com/u/769789?v=3","gravatar_id":"","url":"https://api.github.com/users/johannessteu","html_url":"https://github.com/johannessteu","followers_url":"https://api.github.com/users/johannessteu/followers","following_url":"https://api.github.com/users/johannessteu/following{/other_user}","gists_url":"https://api.github.com/users/johannessteu/gists{/gist_id}","starred_url":"https://api.github.com/users/johannessteu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johannessteu/subscriptions","organizations_url":"https://api.github.com/users/johannessteu/orgs","repos_url":"https://api.github.com/users/johannessteu/repos","events_url":"https://api.github.com/users/johannessteu/events{/privacy}","received_events_url":"https://api.github.com/users/johannessteu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/johannessteu/neos-development-collection/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-06T03:05:31Z","updated_at":"2016-09-20T19:02:28Z","closed_at":"2016-09-20T19:02:28Z","body":"Jira issue originally created by user ishowernaked:\n\n#### The problem\r\nWhen a user has been successfully authenticated by an authentication provider other than `Typo3BackendProvider` (LDAP for example) he or she gets endlessly redirected to the login page > backend > login page > backend > etc.. (even when the user has been assigned TYPO3.Neos:Administrator permissions)\r\n\r\n#### Part 1\r\n\r\nIn \r\n```java\r\n\\TYPO3\\Neos\\Controller\\Backend\\BackendController::indexAction\r\n```\r\nthe method\r\n```java\r\n\\TYPO3\\Neos\\Service\\BackendRedirectionService::getAfterLoginRedirectionUri\r\n```\r\nis called to compute the URI a user is being redirected to. (most likely after login)\r\n\r\nThe way **it is** currently implemented: The user is redirected to the login page when the BackendRedirectionService was unable to determine the redirection URI. (i.e. the service method `getAfterLoginRedirectionUri` returned `NULL`)\r\n\r\nHow **it should be**: The user should only be redirected to the login page if he or she is not authorized to access the backend.\r\n\r\n#### Part 2\r\n\r\nThe issues lie in the\r\n```java\r\n\\TYPO3\\Neos\\Service\\BackendRedirectionService::getAfterLoginRedirectionUri\r\n```\r\nmethod where the methods\r\n```java\r\n  \\TYPO3\\Neos\\Service\\UserService::getBackendUser\r\n  -> \\TYPO3\\Neos\\Domain\\Service\\UserService::getCurrentUser\r\n    -> \\TYPO3\\Neos\\Domain\\Service\\UserService::getUser\r\n```\r\nand\r\n```java\r\n  \\TYPO3\\Neos\\Service\\UserService::getUserWorkspaceName\r\n  -> \\TYPO3\\Neos\\Service\\UserService::getPersonalWorkspaceName\r\n    -> \\TYPO3\\Neos\\Domain\\Service\\UserService::getCurrentUser\r\n      -> \\TYPO3\\Neos\\Domain\\Service\\UserService::getUser\r\n    -> \\TYPO3\\Neos\\Domain\\Service\\UserService::getUsername\r\n```\r\nare called.\r\n\r\nBoth methods `\\TYPO3\\Neos\\Domain\\Service\\UserService::getUser` and `\\TYPO3\\Neos\\Domain\\Service\\UserService::getUsername` have a 2 parameter signature, where the second argument is the `$authenticationProviderName`.\r\nHowever, they are called without the second parameter in `\\TYPO3\\Neos\\Domain\\Service\\UserService::getCurrentUser` and `\\TYPO3\\Neos\\Service\\UserService::getPersonalWorkspaceName` thus resulting in `\\TYPO3\\Neos\\Domain\\Service\\UserService::$defaultAuthenticationProviderName = 'Typo3BackendProvider'` being assumed.\r\n\r\netc.\r\n\r\n#### Part 3 (ideas)\r\n\r\nThe `TYPO3\\Flow\\Security\\Account` model has a public method `getAuthenticationProviderName()` to retrieve the provider name for a given account. So why even pass the name to the methods mentioned above? Imo there's not even a need for a default value.\r\n\r\nThe method `\\TYPO3\\Neos\\Domain\\Service\\UserService::getUser` is called twice resulting in 2 equal database queries. etc.\r\n\r\nIn `\\TYPO3\\Neos\\Service\\BackendRedirectionService::getAfterLoginRedirectionUri` the method `\\TYPO3\\Neos\\Service\\UserService::getBackendUser` is called but `\\TYPO3\\Neos\\Service\\UserService` is meant to be replaced by `\\TYPO3\\Neos\\Domain\\Service\\UserService` so we should actually call `\\TYPO3\\Neos\\Domain\\Service\\UserService::getCurrentUser` instead.\r\n\r\nSimilarly `\\TYPO3\\Neos\\Service\\BackendRedirectionService::getAfterLoginRedirectionUri` should not call the deprecated method `\\TYPO3\\Neos\\Service\\UserService::getUserWorkspaceName` and workspace operations should be assembled into the new Domain-Service instead.\r\n\r\netc.\r\n\r\n#### Part 4 (how I fixed the backend login problem)\r\n\r\nIn `\\TYPO3\\Neos\\Domain\\Service\\UserService::getCurrentUser` I had to change the line from\r\n```php\r\nreturn $this->getUser($account->getAccountIdentifier());\r\n```\r\nto\r\n```php\r\nreturn $this->getUser($account->getAccountIdentifier(), $account->getAuthenticationProviderName());\r\n```\r\nand `\\TYPO3\\Neos\\Service\\UserService` became\r\n```php\r\n<?php\r\nnamespace TYPO3\\Neos\\Service;\r\n// ...\r\nclass UserService\r\n{\r\n  // ...\r\n  /****\r\n   * @Flow\\Inject\r\n   * @var \\TYPO3\\Flow\\Security\\Context\r\n   */\r\n   protected $securityContext;\r\n   // ...\r\n   public function getPersonalWorkspaceName()\r\n   {\r\n    // ...\r\n    $account = $this->securityContext->getAccount();\r\n    $username = $this->userDomainService->getUsername($currentUser, $account->getAuthenticationProviderName());\r\n    // ..\r\n  }\r\n  // ...\r\n}\r\n```\r\nThis is pretty dirt though and I don't even know what the impact on other components is. (I didn't find any tests? :p)\n\n Jira-URL: https://jira.neos.io/browse/NEOS-1840"}}
{"actor":{"display_login":"johannessteu"}}