Review main Merged Breaking

39234[!!!][FEATURE] BE Login form API

Helmut Hummel CR +2 V +2 Expert +1099 −717 updated 10/04/17, 08:18

Commit message

With the new login screen (introduced in 7.2) the possibility to
override or extend the login template was removed.
The old globals ``$GLOBALS['TBE_STYLES']['htmlTemplates']`` was
removed without replacement.

With this patch we introduce a new way to extend the login form and
add a BE login form API.

Review

  • Code review CR +2
    • Anja Leichsenring +2
    • Markus Klein +1
    • Frank Nägler +1
    • Christian Kuhn +1
  • Verified V +2
    • Anja Leichsenring +2
    • Markus Klein +1
    • Frank Nägler +1
    • Christian Kuhn +1

Issues 1

Files 29

Show 9 more files

Review log 97

Show 72 earlier messages
  1. Helmut Hummel uploaded patch set 1 05/03/15, 11:42

  2. Frank Nägler uploaded patch set 2 05/03/15, 14:18

  3. Frank Nägler uploaded patch set 3 05/03/15, 15:11

  4. Frank Nägler uploaded patch set 4 05/03/15, 15:22

  5. Torben Hansen uploaded patch set 5 05/03/15, 17:44

  6. Torben Hansen commented on patch set 5 05/03/15, 17:54

    Great work! Tested with my YubiKey 2FA extension and it works as expected.
  7. Markus Klein commented on patch set 5 CR -1 05/03/15, 18:19

    Dislike.. writing to Helmut in Slack.
  8. Frank Nägler uploaded patch set 6 05/14/15, 19:07

  9. Frank Nägler uploaded patch set 7 05/14/15, 19:10

  10. Frank Nägler commented on patch set 7 05/14/15, 19:10

    this patch is still WIP and we need to change some more things.
  11. Frank Nägler uploaded patch set 8 05/14/15, 19:18

  12. Markus Klein commented on patch set 8 05/15/15, 12:40

    What do you think about kicking the whole challenged stuff in a separate patch first? lets create a subtask on forge for that. Steps would be: * kick challenged stuff from Core * remove openid parts from current belogin * bring new API to live * re-implement usernamepassword-provider * re-implement openid-provider
    [WIP][!!!][FEATURE] BE Login form API

    LoginController.php:119

    provider
  13. Markus Klein commented on patch set 8 CR -1 05/16/15, 00:09

    This is the removal of (super)challenged https://review.typo3.org/39576
  14. Frank Nägler uploaded patch set 9 05/17/15, 14:19

  15. Frank Nägler commented on patch set 9 CR -2 05/17/15, 14:20

    still wip
  16. Frank Nägler uploaded patch set 10 05/18/15, 21:36

  17. Markus Klein commented on patch set 10 CR -1 05/18/15, 22:12

    Login.js:94

    you duplicated that code!

    Feature-66669-AddEextensionPointsToLoginTemplate.rst:2

    needs to be completely rewritten

    OpenidProvider.php:36

    should be "Openid" right?

    ext_localconf.php:51

    this is not needed. php generates the intermediate array without notices or warnings
  18. Markus Klein commented on patch set 10 05/18/15, 22:26

    I'd change the systematic a bit. I'd provide a Login-Layout by the Core and all providers have to use it in their Fluid templates. I'd make the rsaauth provider extend the usernamepassword-provider and override its registration completely in ext_localconf

    LoginController.php:307

    phpdoc: first paragraph is function title so a empty line must be added before this

    LoginController.php:389

    would extract that to some sort of API as well. no help to have this hardcoded here. but maybe in a followup patch then.

    LoginController.php:503

    what is this good for? I wouldn't provide such a thing at all.

    LoginController.php:595

    bool

    LoginProviderInterface.php:23

    description missing. we need to precisely describe what each methods has to be used for.

    UsernamePasswordProvider.php:25

    not needed

    Login.html:59

    create a partial for that?
  19. Markus Klein commented on patch set 10 05/18/15, 22:32

    LoginController.php:137

    what if backend is not available? I'd take the one with the highest sorting number

    LoginController.php:271

    we should check the interface before creating the instance at all.

    LoginController.php:272

    disagree here. we do not let any registered provider interfere with other. We only render the one selected, we shouldn't even instantiate another one.

    LoginController.php:280

    as commented in another file: lets not create a dedicated view for the provider, but use $this->view and let the provider specify the layout we provide.
  20. Frank Nägler commented on patch set 10 05/19/15, 08:20

    on it
  21. Frank Nägler commented on patch set 10 05/19/15, 10:06

    will push a new patchset later, still on it

    LoginController.php:137 Reply

    Done

    LoginController.php:307 Reply

    Done

    LoginController.php:389 Reply

    this should be part of a followup, the interfaces (frontend and backend) hardcoded since years. This should be refactored later with the possibility to extend the interfaces, I think it would make sense to add custom interfaces or "jump points", e.g. jump to Page "Foo" or Page "Bar" in FE.

    LoginController.php:503 Reply

    will be removed before merge, I used this method to make all public properties protected. after I have checked all properties, this and the __set method will be removed.

    LoginController.php:595 Reply

    Done

    LoginProviderInterface.php:23 Reply

    Done

    UsernamePasswordProvider.php:25 Reply

    Done

    Login.html:59 Reply

    Done

    Login.js:94 Reply

    Done

    OpenidProvider.php:36 Reply

    Done

    ext_localconf.php:51 Reply

    Done
  22. Frank Nägler uploaded patch set 11 05/19/15, 22:38

  23. Frank Nägler commented on patch set 10 05/19/15, 22:39

    LoginController.php:271 Reply

    Done

    LoginController.php:272 Reply

    Done

    LoginController.php:280 Reply

    Done
  24. Frank Nägler uploaded patch set 12 05/19/15, 22:48

  25. Markus Klein uploaded patch set 13 05/20/15, 02:29

  26. Markus Klein commented on patch set 12 05/20/15, 02:29

    All fixed in set 13

    LoginController.php:26

    unused imports

    LoginController.php:239

    I'll kick that

    LoginController.php:248

    this option does not exist anymore

    LoginController.php:262

    why removing that? does not hurt us, let's bring it back.

    LoginController.php:265

    , TRUE

    LoginController.php:265

    CGL

    LoginController.php:269

    why do we actually need 2 methods? IMO 1 suffices

    LoginController.php:284

    kicking this function as well

    LoginController.php:351

    I actually want to get rid of this code somehow. maybe a followup

    LoginController.php:380

    The language file is not yet loaded here, due to the move of the get..template() function in the main() function

    LoginController.php:458

    No label of this file is used via global $lang.

    LoginController.php:477

    variable naming

    LoginController.php:480

    no need to run the loop for only a single run.

    LoginController.php:499

    The classical.... Math is the solution: return $b['sorting']-$a['sorting']

    LoginController.php:515

    bad practise: throw an exception here

    Login.html:9

    we can compare strings directly already for quite some time. ;-)

    Login.js:210

    this JS should go into the dedicated JS for the usernamepasswordprovider

    ext_localconf.php:23

    Resources... file

    ext_localconf.php:53

    Resources... file

    ext_localconf.php:39

    only override the provider here, the remainder must be preserved
  27. Markus Klein commented on patch set 13 CR +1 V +1 05/20/15, 02:36

    todo: feature rst

    Feature-66669-BeLoginFromAPI.rst:8

    don't forget this
  28. Markus Klein commented on patch set 13 05/20/15, 09:30

    LoginController.php:242

    even better maybe: is_subclass_of
  29. Andreas Kienast commented on patch set 13 05/20/15, 09:38

    LoginController.php:242 Reply

    +1 for is_subclass_of, there is no need to get an array
  30. Frank Nägler uploaded patch set 14 05/20/15, 21:15

  31. Frank Nägler commented on patch set 13 05/20/15, 21:15

    LoginController.php:242 Reply

    Done

    LoginController.php:242 Reply

    Done

    Feature-66669-BeLoginFromAPI.rst:8 Reply

    Done
  32. Frank Nägler voted on patch set 14 CR 0 05/20/15, 21:16

  33. Markus Klein uploaded patch set 15 05/20/15, 21:41

  34. Markus Klein voted on patch set 15 CR +2 V +1 05/20/15, 21:42

  35. Markus Klein uploaded patch set 16 05/20/15, 22:01

  36. Markus Klein commented on patch set 16 V +1 CR +2 05/20/15, 22:02

    Updated Breaking rst
  37. Frank Nägler commented on patch set 16 05/20/15, 22:03

    @Torben can you test the patch with your extension?
  38. Xavier Perseguers commented on patch set 16 CR -1 05/21/15, 07:00

    LoginController.php:460

    We already have a global key for backend related information: "BE", please reuse that. Furthermore, this looks like configuration of the "backend" extension, and as such it belongs to $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']
  39. Frank Nägler commented on patch set 16 05/21/15, 07:28

    LoginController.php:460 Reply

    thx, looks like a mistake, should be $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend'] ...
  40. Frank Nägler uploaded patch set 17 05/21/15, 10:47

  41. Markus Klein voted on patch set 17 CR +1 V +1 05/21/15, 10:59

  42. Torben Hansen commented on patch set 17 05/21/15, 11:01

    The new concept does not cover the situation of having multiple LoginProviders extending the same class (e.g. UsernamePasswordLoginProvider). With the new patch, it is only possible to extend the UsernamePasswordLoginProvider once. Typically, RSA Auth already extends UsernamePasswordLoginProvider, so when I register my LoginProvider (which also extends UsernamePasswordLoginProvider by adding a third field to the login screen) the render function of the RsaAuthLoginProvider gets overridden by my LoginProvider. This results in the situation, that it is not possible to login any more, since the RSA Auth process fails. I could resolve the problem by extending RsaAuthLoginProvider instead of UsernamePasswordLoginProvider. But when a user uninstalls rsaauth or adds another authservice, which also extends UsernamePasswordLoginProvider (edgecase of course), the login functionality will be broken. Is this intended to work so?
  43. Markus Klein commented on patch set 17 05/21/15, 12:02

    Thanks for sharing your usecase here. This is indeed not easily doable. Generally your usecase would be doable if rsaauth would plugin differently, right? You could then just extend the default login and you're done.
  44. Torben Hansen commented on patch set 17 05/21/15, 12:19

    Yes, if rsaauth would plugin differently, I could just extend the default login.
  45. Markus Klein commented on patch set 17 05/21/15, 13:14

    But you actually only need to adjust the HTML template, right? So having a possibility to replace the form HTML of the default login, would already do the job.
  46. Torben Hansen commented on patch set 17 05/21/15, 15:19

    Yes, I only need to add an additional field to the HTML Template. I also use $TBE_STYLES['stylesheet2'] to add an additional CSS file to the TYPO3 installation. I emailed with an extension author this week, who used $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] to add additional JS to the backend login in order to implement a FIDO U2F authentication for the backend login. Instead of using the loginScriptHook, the extension author could use an own LoginProvider to add extra fields and JS files. So in gereral I think it is required to extend the login form with custom HTML (e.g. a field), additional JS and CSS.
  47. Markus Klein commented on patch set 17 V 0 CR -2 05/21/15, 15:31

    Ok seems like extending the default login form is more common than I expected. I expected that you will mostly replace the whole form anyway. I'll talk with Frank again about the concept. I consider shifting rsaauth out of the class hierarchy, such that you can directly extend the default login, with your own login. That would open all doors then for HTML, JS and CSS modifications and still there would be some way to inject rsaauth. Will report back here.
  48. Frank Nägler commented on patch set 17 05/21/15, 20:50

    Possible solution with the current implementation would be: if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('rsaauth')) { $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend'][\TYPO3\CMS\Backend\Controller\LoginController::class]['loginProviders']['backend']['provider'] = \TYPO3\CMS\Foo\LoginProvider\FooRsaAuthLoginProvider::class; } else { $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend'][\TYPO3\CMS\Backend\Controller\LoginController::class]['loginProviders']['backend']['provider'] = \TYPO3\CMS\Foo\LoginProvider\FooUsernamePasswordLoginProvider::class; } for that @FooRsaAuthLoginProvider@ must extend @RsaAuthLoginProvider@ and @FooUsernamePasswordLoginProvider@ must extend @UsernamePasswordLoginProvider@
  49. Frank Nägler uploaded patch set 18 05/21/15, 22:23

  50. Markus Klein uploaded patch set 19 05/21/15, 22:40

  51. Markus Klein voted on patch set 18 CR 0 05/21/15, 22:41

  52. Markus Klein voted on patch set 19 CR 0 05/21/15, 22:41

  53. Markus Klein voted on patch set 19 CR +1 V +1 05/21/15, 22:44

  54. Markus Klein uploaded patch set 20 05/21/15, 22:47

  55. Markus Klein voted on patch set 20 CR +1 V +1 05/22/15, 00:29

  56. Andreas Kienast uploaded patch set 21 05/22/15, 06:40

  57. Andreas Kienast commented on patch set 21 CR +1 V +1 05/22/15, 06:40

    Sorry, found a nitpick.
  58. Torben Hansen commented on patch set 21 V +1 05/22/15, 10:37

    Feature-66669-BeLoginFormAPI.rst:29

    rsaauth does'nt extend another LoginProvider anymore. Should we provide an additional section in this document describing how to extend an existing LoginProvider?

    Feature-66669-BeLoginFormAPI.rst:79

    two
  59. Markus Klein commented on patch set 21 CR -1 05/22/15, 13:33

    Feature-66669-BeLoginFormAPI.rst:29 Reply

    We proof-read this now. We were too tired obviously to get it right.
  60. Markus Klein uploaded patch set 22 05/22/15, 13:40

  61. Markus Klein voted on patch set 22 CR +1 V +1 05/22/15, 13:40

  62. Frank Nägler uploaded patch set 23 05/22/15, 13:54

  63. Frank Nägler commented on patch set 23 05/22/15, 13:54

    only small fix in rst file
  64. Markus Klein voted on patch set 23 CR +1 V +1 05/22/15, 15:19

  65. Christian Kuhn commented on patch set 23 05/22/15, 23:58

    just skimmed roughly, did not yet do a full review and gerrit is shaky currently ... i'll try to give this a full review soon.

    LoginController.php:448

    could we hard code a name here instead of __CLASS__? Furthermore, I have similar code in NodeFactory of https://review.typo3.org/#/c/39662/2/typo3/sysext/backend/Classes/Form/NodeFactory.php - and my code is more defensive (eg. I sanitize the parameters and throw exceptions if the registration is incomplete.
  66. Torben Hansen voted on patch set 23 V +1 05/26/15, 12:38

  67. Frank Nägler commented on patch set 23 CR -1 05/29/15, 15:52

    waiting of feedback by Lolli

    LoginController.php:448 Reply

    What is the reason for not using __CLASS__ ? We use it many times in the core. I am fine to check the data and throw an exception, this is a good practice.
  68. Helmut Hummel commented on patch set 23 05/30/15, 09:58

    LoginController.php:448 Reply

    > What is the reason for not using __CLASS__ ? It is a configuration key, which should not change once the class name changes (although this would be very unlikely). Besides that, it is more explicit to read if the configuration key would written here. At least we should use: TYPO3\CMS\Backend\Controller\LoginController::class as key.
  69. Frank Nägler commented on patch set 23 05/30/15, 13:18

    LoginController.php:448 Reply

    Done
  70. Frank Nägler uploaded patch set 24 05/30/15, 13:20

  71. Markus Klein voted on patch set 24 CR +1 V +1 05/30/15, 22:28

  72. Torben Hansen voted on patch set 24 V +1 05/31/15, 08:05

  1. Andreas Kienast voted on patch set 24 CR +1 V +1 05/31/15, 17:58

  2. Christian Kuhn commented on patch set 24 CR -1 06/03/15, 15:37

    working on it.
  3. Christian Kuhn commented on patch set 24 06/03/15, 16:13

    some comments - i'd slightly change the interface and code some areas a bit more defensive.

    LoginController.php:230

    mmmh, fishy. is this some kind of fallback if a loginProvider was unloaded and you reload to not fatal? if not, please remove class_exists() and throw and exception if not "instanceof" interface.

    LoginController.php:329

    !empty()

    LoginController.php:448

    to my understanding, there *must* be some login provider that is registered, right? throw an exception on empty() ?

    LoginController.php:450

    throw an exception if sorting is not set? What else is mandatory? prodiver for sure, icon-class? label?

    LoginController.php:463

    Sorry, I'm still no fan of \TYPO3\CMS\Backend\Controller\LoginController::class ... couldn't we just remove the whole key? isn't backend/loginProviders enough??

    Feature-66669-BeLoginFormAPI.rst:2

    good file! thx!

    ext_localconf.php:49

    btw: instead of text string "openid" as key, i took a timestamp at different places. this way it will not clash with others, it shows the key is "irrelevant", naming conflicts are easy, you don't need to think about at and still, the entry is at a specific not changing position in the array. what do you think?
  4. Frank Nägler commented on patch set 24 06/03/15, 16:25

    LoginController.php:230 Reply

    exception is a good idea

    LoginController.php:329 Reply

    no, the check is > 1

    LoginController.php:448 Reply

    like before, a good idea, will change it

    LoginController.php:450 Reply

    will check it

    LoginController.php:463 Reply

    I am fine, we can change it.

    ext_localconf.php:49 Reply

    the idea is that you can extend or remove providers, a speaking key is imo nicer in this case. e.g. you can provide an extension super_openid, which extends/replace the origin provider.
  5. Markus Klein commented on patch set 24 06/03/15, 16:27

    LoginController.php:230 Reply

    No fallback intended. Just a validation. An exception might indeed be better.

    LoginController.php:329 Reply

    No: count() > 1 != !empty

    LoginController.php:448 Reply

    that should be checked outside of this function. its sole purpose is to return what is there.

    LoginController.php:450 Reply

    The validation should not happen in the closure.

    LoginController.php:463 Reply

    we found no better alternative yet. but I've no problem with skipping the intermidate part.

    ext_localconf.php:49 Reply

    I'm a bit worried about the readability of "only numbers"
  6. Markus Klein uploaded patch set 25 06/04/15, 12:28

  7. Markus Klein commented on patch set 25 V -1 CR +1 06/04/15, 12:30

    the last used provider shall be restored. will add this.
  8. Markus Klein uploaded patch set 26 06/04/15, 12:50

  9. Markus Klein voted on patch set 26 CR +1 V +1 06/04/15, 12:51

  10. Markus Klein commented on patch set 26 CR 0 V 0 06/04/15, 13:03

    LoginController.php:110

    needs validation as this is written to uc.

    LoginController.php:114

    only used once, can be removed
  11. Markus Klein uploaded patch set 27 06/04/15, 13:14

  12. Markus Klein commented on patch set 27 CR +1 V +1 06/04/15, 13:16

    LoginController.php:259

    This needs some more thoughts. We do this in a followup as this is not critical.
  13. Torben Hansen voted on patch set 27 V +1 06/04/15, 19:02

  14. Christian Kuhn voted on patch set 27 CR +1 06/04/15, 19:47

  15. Christian Kuhn voted on patch set 27 V +1 06/04/15, 19:48

  16. Frank Nägler voted on patch set 27 V +1 CR +1 06/04/15, 19:50

  17. Anja Leichsenring commented on patch set 27 06/04/15, 20:02

    Feature-66669-BeLoginFormAPI.rst:61

    object

    Feature-66669-BeLoginFormAPI.rst:62

    may -> must. This is imperative, no option.
  18. Markus Klein commented on patch set 27 06/04/15, 20:20

    Feature-66669-BeLoginFormAPI.rst:61 Reply

    You have to set it within the method of the object implementing the interface.

    Feature-66669-BeLoginFormAPI.rst:62 Reply

    Agreed.
  19. Anja Leichsenring uploaded patch set 28 06/04/15, 20:26

  20. Markus Klein voted on patch set 28 CR +1 V +1 06/04/15, 20:28

  21. Frank Nägler voted on patch set 28 V +1 CR +1 06/04/15, 20:28

  22. Anja Leichsenring voted on patch set 28 CR +2 V +2 06/04/15, 21:20

  23. Christian Kuhn voted on patch set 28 CR +1 V +1 06/04/15, 21:58

  24. Anja Leichsenring merged patch set 28 06/05/15, 05:04

  25. Benni Mack commented on patch set 29 10/04/17, 08:18

    Login.html:54

    this strikes me as being plainly wrong, as it redirects to a relative file within the server...