Review main Merged

96556[TASK] Add authentication pipeline contracts

Oli Bartsch CR +2 V +2 Expert +1264 −2 updated 10/25/26, 22:11

Commit message

Authentication code needs one way to resolve who is calling, whether
the backend, the frontend or a token based API is asked. The contracts
for that are added to EXT:core as internal groundwork for the
authentication modernization, without changing how TYPO3 authenticates
today. The backend and frontend login are moved onto these contracts in
a follow-up change.

An authenticator resolves a request in a realm to one of four
outcomes: Authenticated with a Principal, Challenge with the response
that starts an interactive step, Failure, or NotApplicable for a
request it has no credentials for. The AuthenticatorManager asks the
authenticators of the requested realm in priority order, and the first
conclusive outcome wins. Like the attributes of a Symfony security
token, an Authenticated outcome can carry further facts about the
authentication, such as the legacy user object during the migration.

Authenticators are registered for the realms they serve with the
repeatable #[AsAuthenticator(realm: ..., priority: ...)] attribute,
comparable to the authenticators of a Symfony firewall, so that an
authenticator is never asked for another realm. Next to the backend
and frontend realms, custom realms can be named, for example for a
token based API. Like the backend realm, they authenticate backend
users, and the backend and frontend identifiers are reserved. An
authenticator registered for the frontend serves the frontend of
every site, and the manager refuses a principal that was established
for another realm than the requested one.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Wouter Wolters +1
    • Benni Mack +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Oliver Klee +1
    • Wouter Wolters +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 22

Show 2 more files

Review log 1926

Show 1 earlier messages
  1. Oli Bartsch uploaded patch set 1 10/09/26, 10:18

  1. core-ci voted on patch set 1 V +1 10/09/26, 10:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110581

  2. Oli Bartsch rebased onto patch set 2 V +1 10/09/26, 13:01

  3. core-ci voted on patch set 2 V -1 10/09/26, 13:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110605

  4. Oli Bartsch rebased onto patch set 3 V -1 10/09/26, 20:49

  5. core-ci voted on patch set 3 V +1 10/09/26, 21:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110718

  6. Oli Bartsch uploaded patch set 4 V +1 10/12/26, 12:32

  7. core-ci voted on patch set 4 V +1 10/12/26, 12:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110904

  8. Oli Bartsch rebased onto patch set 5 V +1 10/12/26, 19:57

  9. core-ci voted on patch set 5 V +1 10/12/26, 20:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110940

  10. Benni Mack uploaded patch set 6 V +1 10/25/26, 13:31

  11. Benni Mack commented on patch set 6 10/25/26, 13:37

    I did some changes due to reworking Authorization as well: 1. Authenticators are bound to realms when they're registered. - They now register with a repeatable #[AsAuthenticator(realm: 'backend', priority: 10)]. 'frontend' covers the frontend of every site, and other names are custom realms such as 'api'. - A new compiler pass, AuthenticatorPass, builds a list of authenticators per realm, sorted by priority. It refuses services that don't implement the interface, registrations without a realm, and invalid realm names. - The manager only asks the authenticators of the requested realm, and loads them lazily from a service locator. - The old interface autoconfiguration (AsTaggedItem priority) is removed. The check that rejects a principal from another realm stays as a second line of defence. 2. supports() is gone; NotApplicable stays. 95284's legacy adapter only learns inside authenticate(), after running the old auth-service chain, that a request has no user. So only NotApplicable can express that. With realms bound at registration, the main job of supports() disappears anyway. 3. Badges are removed. Authenticated now carries attributes, like a Symfony security token: hasAttribute() and getAttribute(), which throws for an unknown name. The legacy user becomes e.g. ['legacyUser' => $user]. "Badge" stays free for the planned in-between object (the Passport). 4. AuthenticationManager is renamed to AuthenticatorManager. The token storage comes with the authorization checker commit later.
  12. Benni Mack voted on patch set 6 CR +1 V +1 10/25/26, 13:37

  13. core-ci voted on patch set 6 V +1 10/25/26, 13:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112493

  14. Wouter Wolters commented on patch set 6 10/25/26, 13:52

    AuthenticatorPass.php:68

    ! Realm::isBackend($realm) && ! Realm::isFrontend($realm) can this be used here?
  15. Oliver Klee voted on patch set 6 V +1 10/25/26, 14:07

  16. Benni Mack commented on patch set 6 10/25/26, 17:05

    AuthenticatorPass.php:68 Reply

    Not directly: isBackend()/isFrontend() are instance methods, and Realm::custom() refuses the reserved identifiers, so there's no Realm to ask yet. I've added Realm::fromIdentifier(), which maps a registered identifier to the backend, the general frontend or a custom realm, and the pass uses that now. No more string literals or comment there.
  17. Oli Bartsch commented on patch set 6 CR -1 10/25/26, 17:08

    Reviewing
  18. Oli Bartsch uploaded patch set 7 CR +1 V +1 10/25/26, 19:39

  19. Oli Bartsch commented on patch set 7 CR +1 V +1 10/25/26, 19:40

    Reply

    Done
  20. Benni Mack voted on patch set 7 CR +1 V +1 10/25/26, 19:57

  21. Wouter Wolters voted on patch set 7 CR +1 V +1 10/25/26, 20:00

  22. core-ci voted on patch set 7 V +1 10/25/26, 20:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112537

  23. Oliver Klee voted on patch set 7 V +1 10/25/26, 21:19

  24. Oli Bartsch voted on patch set 7 CR +2 V +2 10/25/26, 22:11

  25. Oli Bartsch merged patch set 8 10/25/26, 22:11