This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component
Fabien Potencier df7099cb2d feature #39153 [Security] Automatically register custom authenticator as entry_point (if supported) (wouterj)
This PR was squashed before being merged into the 5.2 branch.

Discussion
----------

[Security] Automatically register custom authenticator as entry_point (if supported)

| Q             | A
| ------------- | ---
| Branch?       | 5.2 (hopefully?)
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #37068
| License       | MIT
| Doc PR        | -

@weaverryan came up with exactly the same issue as proposed by a contributor before (see referenced ticket). Back then, it was decided impossible to fix: see https://github.com/symfony/symfony/pull/37075. However, after some thinking we came up with a way to fix the issue and improve the DX for custom authenticators.

The new authenticators are no longer required to implement `AuthenticationEntryPointInterface` (required for internal authenticators like the `RememberMeAuthenticator` and pre authenticated ones). This PR uses a compiler pass to check if a custom authenticator is supported:

```yaml
security:
  firewalls:
    main:
      # in any case, if an entry_point is already configured it'll not be overriden
      # (http_basic remains the entry point here)
      http_basic: ~
      custom_authenticator: App\Security\CustomAuthenticator
      entry_point: http_basic

      # if only one custom authenticator implements AuthenticationEntryPointInterface,
      # it's automatically configured as the entry point
      custom_authenticator: App\Security\CustomAuthenticator
      custom_authenticators: [App\Security\CustomAuthenticator, App\Security\NoEntryPointAuthenticator]

      # if no custom authenticator implements AuthenticationEntryPointInterface,
      # an error is thrown
      custom_authenticator: App\Security\NoEntryPointAuthenticator

      # if more than one authenticator implements AuthenticationEntryPointInterface,
      # the entry point must be configured explicitly (or an error is thrown)
      custom_authenticators: [App\Security\CustomAuthenticator, App\Security\AnotherCustomAuthenticator]
      entry_point: App\Security\CustomAuthenticator
```

---

I know this is very late for Symfony 5.2. It would be good to decide whether this can be included in the release, in order to smooth out the biggest struggle for people using custom authenticators for the first time.

Commits
-------

cab0672248 [Security] Automatically register custom authenticator as entry_point (if supported)
2020-11-27 11:24:59 +01:00
..
Asset Merge branch '4.4' into 5.1 2020-10-24 14:01:57 +02:00
BrowserKit [Browserkit] Add changelog entry for request parameters string cast 2020-11-14 12:04:29 +01:00
Cache Merge branch '5.1' into 5.2 2020-11-21 10:39:55 +01:00
Config Merge branch '5.1' into 5.2 2020-11-16 19:02:40 +01:00
Console Merge branch '5.1' into 5.2 2020-11-27 01:39:34 +01:00
CssSelector Merge branch '4.4' into 5.1 2020-10-28 22:31:18 +01:00
DependencyInjection Merge branch '5.1' into 5.2 2020-11-13 10:44:33 +01:00
DomCrawler Merge branch '4.4' into 5.1 2020-10-24 14:01:57 +02:00
Dotenv Merge branch '4.4' into 5.1 2020-11-18 10:42:36 +01:00
ErrorHandler Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
EventDispatcher Merge branch '5.1' into 5.x 2020-11-01 17:14:45 +01:00
ExpressionLanguage Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
Filesystem Merge branch '4.4' into 5.1 2020-11-12 10:58:18 +01:00
Finder Merge branch '4.4' into 5.1 2020-11-18 10:42:36 +01:00
Form Merge branch '5.1' into 5.2 2020-11-13 10:44:33 +01:00
HttpClient Merge branch '5.1' into 5.2 2020-11-21 10:39:55 +01:00
HttpFoundation feature #39128 [HttpFoundation] Deprecate BinaryFileResponse::create() (derrabus) 2020-11-27 07:13:25 +01:00
HttpKernel Bump Symfony version to 5.2.0 2020-11-21 09:49:39 +01:00
Inflector Merge branch '4.4' into 5.1 2020-10-24 14:01:57 +02:00
Intl Merge branch '4.4' into 5.1 2020-11-03 12:59:17 +01:00
Ldap Merge branch '5.1' into 5.2 2020-11-16 19:02:40 +01:00
Lock Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
Mailer Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
Messenger bug #39004 [Messenger] Fix JSON deserialization of ErrorDetailsStamp and normalization of FlattenException::$statusText (Jean85) 2020-11-10 07:17:29 +01:00
Mime remove reflection-docblock from mime requirements 2020-10-30 15:55:39 +01:00
Notifier [Notifier] Add unit tests for NullMessage, NullTransport and NullTransportFactory 2020-11-03 00:54:11 +01:00
OptionsResolver Merge branch '5.1' into 5.x 2020-10-24 14:08:07 +02:00
Process Merge branch '5.1' into 5.x 2020-11-02 16:47:15 +01:00
PropertyAccess Merge branch '5.1' into 5.x 2020-11-01 17:14:45 +01:00
PropertyInfo Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
RateLimiter feature #38664 [RateLimiter] Moved classes implementing LimiterInterface to a new namespace (Nyholm) 2020-10-25 09:35:39 +01:00
Routing Merge branch '5.1' into 5.2 2020-11-27 01:39:34 +01:00
Security feature #39153 [Security] Automatically register custom authenticator as entry_point (if supported) (wouterj) 2020-11-27 11:24:59 +01:00
Semaphore Merge branch '5.1' into 5.x 2020-10-24 14:08:07 +02:00
Serializer Merge branch '5.1' into 5.2 2020-11-27 01:39:34 +01:00
Stopwatch Merge branch '5.1' into 5.x 2020-11-01 17:14:45 +01:00
String Merge branch '5.1' into 5.x 2020-10-24 14:08:07 +02:00
Templating Merge branch '4.4' into 5.1 2020-10-24 14:01:57 +02:00
Translation Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
Uid Merge branch '5.1' into 5.x 2020-10-24 14:08:07 +02:00
Validator bug #39070 [Validator] Remove IsinValidator's validator dependency (derrabus) 2020-11-13 23:00:16 +01:00
VarDumper Merge branch '5.1' into 5.2 2020-11-27 01:39:34 +01:00
VarExporter Merge branch '4.4' into 5.1 2020-10-28 22:31:18 +01:00
WebLink Merge branch '4.4' into 5.1 2020-10-24 14:01:57 +02:00
Workflow Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
Yaml Merge branch '4.4' into 5.1 2020-11-21 10:37:14 +01:00