Commit Graph

54751 Commits

Author SHA1 Message Date
eFrane
ada6f7d315 [Workflow] Add Mermaid.js dumper 2021-04-13 10:42:35 +02:00
Nicolas Grekas
0a32a7df19 minor #40779 [DependencyInjection] Allow calling custom processors directly on EnvConfigurator (jvasseur)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[DependencyInjection] Allow calling custom processors directly on EnvConfigurator

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

This is a proposition of addition to the feature added by https://github.com/symfony/symfony/pull/40682 to allow calling custom processors in the same way we call builtin ones. This is not perfect since it doesn't allow auto-completion for these custom methods but I think this provides a cleaner API for custom processors.

Commits
-------

1d008f76da Allow calling custom processors directly on EnvConfigurator
2021-04-13 09:57:59 +02:00
Foxprodev
f2ee8bc7ae [WebProfiler] Use ControllerReference instead of URL in twig render() 2021-04-13 10:28:22 +03:00
Fabien Potencier
ff0cf61278 feature #40761 [MonologBridge] Reset loggers on workers (l-vo)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[MonologBridge] Reset loggers on workers

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

This PR tries to solve some problems with buffered handlers (FingerCrossed) in workers.

Let's consider the default configuration (`stop_buffering: true`):
- When the threshold is crossed, all logs are flushed. Logs for the current message but also logs of previous messages in the buffer. Although buffer is limited `buffer_size`, it's a shame to keep logs of previous messages.
- When the threshold is crossed, buffering is disabled. So finger crossed configuration is not used anymore, all the logs are flushed as soon as they are written.

Then with (`stop_buffering: false`) (why isn't this the default configuration ?)
- It's a bit better since buffering isn't disabled when the threshold is crossed
- Like with `stop_buffering: true`, logs of previous messages are kept in memory

In a similar way of `DoctrineClearEntityManagerWorkerSubscriber`, this PR adds a `ResetLoggersWorkerSubscribber` to reset resettable loggers.

Integration in Monolog bundle: symfony/monolog-bundle#403

Commits
-------

1d2f7f1f87 [Messenger] Reset loggers on workers
2021-04-13 08:43:12 +02:00
Laurent VOULLEMIER
1d2f7f1f87 [Messenger] Reset loggers on workers 2021-04-13 08:42:46 +02:00
Fabien Potencier
3f42c08abd minor #40786 [Serializer][Validator] Update some phpDoc relative to "getters" (guilliamxavier)
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[Serializer][Validator] Update some phpDoc relative to "getters"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yesish (phpDoc unaccurate after code updates)
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

5046500deb [Serializer][Validator] Update some phpDoc relative to "getters"
2021-04-13 08:32:45 +02:00
Guilliam Xavier
5046500deb [Serializer][Validator] Update some phpDoc relative to "getters" 2021-04-13 08:32:41 +02:00
Fabien Potencier
b8b29012da minor #40770 Update README.md (94noni)
This PR was merged into the 4.4 branch.

Discussion
----------

Update README.md

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes as doc
| Tickets       | see desc
| License       | MIT
| Doc PR        | .

Related to https://packagist.org/packages/symfony/web-server-bundle/stats
Also I do have a question, do Symfony uses the https://getcomposer.org/doc/04-schema.md#abandoned feature?
It can be useful I think

I’ve seen many differents way, inside the repo readme, via github repo description with [DEPRECATED], even marking the repo as readonly
IMHO a similar aproach should be done for all packages of the organisation :)

Commits
-------

37b19d9c06 Update README.md
2021-04-13 08:31:04 +02:00
Antoine Makdessi
37b19d9c06 Update README.md 2021-04-13 08:30:55 +02:00
Fabien Potencier
64cc54835d feature #40785 [Security] Deprecate using UsageTrackingTokenStorage outside the request-response cycle (wouterj)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Security] Deprecate using UsageTrackingTokenStorage outside the request-response cycle

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | yes
| Tickets       | Fix #40778
| License       | MIT
| Doc PR        | -

Currently, you get an "There is currently no session available" exception when using the `security.token_storage` service outside the main request-response cycle (e.g. in a `kernel.terminate` listener). This PR deprecates such usage and requires developers to update their definitions to explicitly use `security.untracked_token_storage` instead.

A different solution would be to silently disable tracking in these cases, but I think that might create some unnecessary technical debt.

Commits
-------

7452476156 [Security] Fix UsageTrackingTokenStorage outside the request cycle
2021-04-13 08:27:23 +02:00
Wouter de Jong
7452476156 [Security] Fix UsageTrackingTokenStorage outside the request cycle 2021-04-13 08:27:14 +02:00
Fabien Potencier
40b4ff8aae feature #40718 [Messenger] Add X-Ray trace header support to the SQS transport (WaylandAce)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Messenger] Add X-Ray trace header support to the SQS transport

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

aws documentation: https://docs.aws.amazon.com/xray/latest/devguide/xray-services-sqs.html

Commits
-------

5fa7ff9541 [Messenger] Added X-Ray trace header support to the SQS transport
2021-04-13 08:23:30 +02:00
Alexander M. Turek
e1f2e81306 bug #40330 [SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped (monteiro)
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #40235 ... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT

When the IDE by mistake puts an empty line in `access_control` in security.yaml there is no warning that we have an empty row, making the rest of routes defined, to be ignored and possible to be accessed by anyone that can authenticate no matter the role.

# How to reproduce the issue

- git clone git@github.com:monteiro/symfony-issue-40235.git
- composer install
- symfony server:start
- open 127.0.0.1:8000/admin with username: "john_user" and password "123456"
- Since that user has only ROLE_USER should not be able to access the route... but because there is an empty line in "access_control" in `security.yaml`, "by mistake" it is possible to access the protected `ROLE_ADMIN` route.

Commits
-------

ee26ce5987 [SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped
2021-04-12 16:25:43 +02:00
Hugo Monteiro
ee26ce5987 [SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped 2021-04-12 16:25:37 +02:00
Alexander M. Turek
8c43fac84c bug #40780 [Cache] Apply NullAdapter as Null Object (roukmoute)
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[Cache] Apply NullAdapter as Null Object

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix https://github.com/symfony/symfony/issues/40753
| License       | MIT
<!--| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

There is a problem with the NullAdapter if I have to add an expression to work:

```php
$adapter = new NullAdapter();
$item = new CacheItem();
$item->set('FooBar');
if (!$adapter->save($item) && !($adapter instanceof NullAdapter)) {
    throw new Exception('Uoh oh');
}
```

So the goal here is to modify the methods that are causing a problem to behave as a Null Object.

Commits
-------

f6818eb7ac [Cache] Apply NullAdapter as Null Object
2021-04-12 16:23:06 +02:00
Mathias STRASSER
f6818eb7ac [Cache] Apply NullAdapter as Null Object 2021-04-12 16:22:57 +02:00
Oskar Stark
9092d5b035 bug #40739 [Notifier] Inject Mailer instead of service locator for FakeSms and FakeChat (OskarStark)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Notifier] Inject Mailer instead of service locator for FakeSms and FakeChat

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fixes #40731
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/15206
| Recipe PR        | https://github.com/symfony/recipes/pull/930

Until now the locator was not injected and therefore not working.

We decided to make the transport name configurable instead of the service_id.

[How is it working?](https://github.com/symfony/symfony/pull/40739#issuecomment-816609850)

### Todos
* [x] add tests
* [x] test in a real project

Commits
-------

0f6d5079cb [Notifier] Inject Mailer instead of service locator for FakeSms and FakeChat
2021-04-12 11:12:52 +02:00
Jérôme Vasseur
1d008f76da Allow calling custom processors directly on EnvConfigurator
Add magic __call method to EnvConfigurator to allow calling custom
processors as methods instead of using the custom method.
2021-04-12 11:09:21 +02:00
Oskar Stark
0f6d5079cb [Notifier] Inject Mailer instead of service locator for FakeSms and FakeChat 2021-04-12 11:05:06 +02:00
Nicolas Grekas
5c660f7554 Merge branch '5.2' into 5.x
* 5.2:
  [HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page
  Revert "minor #40768 [HttpClient] [PHPDoc] Fix 2 remaining return mixed (fancyweb)"
2021-04-12 10:56:19 +02:00
Nicolas Grekas
c3b4e81c23 Merge branch '4.4' into 5.2
* 4.4:
  [HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page
  Revert "minor #40768 [HttpClient] [PHPDoc] Fix 2 remaining return mixed (fancyweb)"
2021-04-12 10:50:37 +02:00
Nicolas Grekas
e05b4efec2 minor #40777 [HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | (not needed)

The current "Welcome Page" has a minor issue related to CSS flexbox. See how the "debug mode" text looks in smaller screens:

![before](https://user-images.githubusercontent.com/73419/114359439-4620d300-9b74-11eb-85c6-ee7afdb937df.png)

The solution is to wrap the contents in a HTML element such as `<p>`, but this PR also does some other minor tweaks. This is how it'd look now:

![after](https://user-images.githubusercontent.com/73419/114359535-5cc72a00-9b74-11eb-86c4-07fba89b8e8f.png)

Commits
-------

ee49cfe2b9 [HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page
2021-04-12 10:48:29 +02:00
Javier Eguiluz
ee49cfe2b9 [HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page 2021-04-12 10:48:24 +02:00
Nicolas Grekas
8451a9fbef minor #40776 [DependencyInjection] improve phpdoc for registerAttributeForAutoconfiguration() (nicolas-grekas)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[DependencyInjection] improve phpdoc for registerAttributeForAutoconfiguration()

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Commits
-------

99e77492f2 [DependencyInjection] improve phpdoc for registerAttributeForAutoconfiguration()
2021-04-12 10:47:46 +02:00
Nicolas Grekas
d359b76907 minor #40775 [HttpClient] Revert "minor #40768 [PHPDoc] Fix 2 remaining return mixed (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] Revert "minor #40768  [PHPDoc] Fix 2 remaining return mixed

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This reverts commit 40d7315202, reversing
changes made to 4e904ec108.

As spotted by the CI and reported in https://github.com/symfony/symfony/pull/40768#issuecomment-817388657

Using `Psr7ResponseInterface|mixed` instead of just `mixed` provides a better DX, by making autocompletion more useful.

Commits
-------

afea0a0dc2 Revert "minor #40768 [HttpClient] [PHPDoc] Fix 2 remaining return mixed (fancyweb)"
2021-04-12 10:22:28 +02:00
Nicolas Grekas
99e77492f2 [DependencyInjection] improve phpdoc for registerAttributeForAutoconfiguration() 2021-04-12 09:43:00 +02:00
Nicolas Grekas
afea0a0dc2 Revert "minor #40768 [HttpClient] [PHPDoc] Fix 2 remaining return mixed (fancyweb)"
This reverts commit 40d7315202, reversing
changes made to 4e904ec108.
2021-04-12 08:52:04 +02:00
Alexander M. Turek
364742f18c Merge branch '5.2' into 5.x
* 5.2:
  [HttpClient][PHPDoc] Fix 2 remaining return mixed
  [Cache] [FrameworkBundle] Fix logging for TagAwareAdapter
  [Route] Better inline requirements and defaults parsing
  Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest
  [PhpUnitBridge] Fix phpunit symlink on Windows
  [Yaml] Fixed infinite loop when parser goes through an additional and invalid closing tag
  [Form] Fix 'invalid_message' use in multiple ChoiceType
2021-04-12 01:07:08 +02:00
Alexander M. Turek
86c9c3b0f8 Merge branch '4.4' into 5.2
* 4.4:
  [HttpClient][PHPDoc] Fix 2 remaining return mixed
  [Cache] [FrameworkBundle] Fix logging for TagAwareAdapter
  [Route] Better inline requirements and defaults parsing
  Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest
  [PhpUnitBridge] Fix phpunit symlink on Windows
  [Yaml] Fixed infinite loop when parser goes through an additional and invalid closing tag
2021-04-12 00:55:21 +02:00
Nicolas Grekas
91fbc90238 Autowire arguments using attributes 2021-04-11 23:05:41 +02:00
Alexander M. Turek
b86aa3d068 [DependencyInjection] Bind constructor arguments via attributes 2021-04-11 23:04:00 +02:00
Alexander M. Turek
05cdefadd9 minor #40772 [TwigBundle] Require TwigBridge 5.3 for SerializerExtension (wouterj)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[TwigBundle] Require TwigBridge 5.3 for SerializerExtension

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Caught while testing 5.x in one of our apps. Without this, you'll get an error when you're using TwigBridge <5.3 with TwigBundle 5.3+:

```
In KernelDevDebugContainer.php line 944:

  Attempted to load class "SerializerExtension" from namespace "Symfony\Bridge\Twig\Extension".
```

Commits
-------

e4cedfa21a [TwigBundle] Require TwigBridge 5.3 for SerializerExtension
2021-04-11 22:58:43 +02:00
Wouter de Jong
e4cedfa21a [TwigBundle] Require TwigBridge 5.3 for SerializerExtension 2021-04-11 22:22:16 +02:00
Nicolas Grekas
cb0b07e8c1 feature #40682 [DependencyInjection] Add env() and EnvConfigurator in the PHP-DSL (fancyweb)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[DependencyInjection] Add env() and EnvConfigurator in the PHP-DSL

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Recently, I have been using env var processors a lot. This is a proposition to improve the DX a bit when you use the PHP-DSL to configure services.

Firstly, I am "annoyed" by the fact that I can do `param('my_param')` but not `env('MY_ENV')`.

Secondly, long chains of env var processors (eg: `%env(default:my_param:key:path:url:MY_ENV_VAR)` have two issues:
- you must construct and read them in "reverse"
- some env var processor are actually composed of 2 parts (key:path), you don't distinguish them easily from the rest

Before:
```php
->arg('$myArg', '%env(default:my_param:key:path:url:MY_ENV_VAR)%')
```

After:
```php
->arg(
    '$myArg',
    env('MY_ENV_VAR')
        ->url()
        ->key('path')
        ->default('my_param')
)
```

Custom env var processor would be callable with `->custom('my_custom_env_var_processor')` or you could extend the configurator and add your own methods.

WDYT?

Commits
-------

5f0fe3235f [DependencyInjection] Add env() and EnvConfigurator in the PHP-DSL
2021-04-11 19:27:24 +02:00
Nicolas Grekas
40d7315202 minor #40768 [HttpClient] [PHPDoc] Fix 2 remaining return mixed (fancyweb)
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] [PHPDoc] Fix 2 remaining return mixed

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Two cases I forgot in https://github.com/symfony/symfony/pull/40728 😕

Commits
-------

97a43e1dab [HttpClient][PHPDoc] Fix 2 remaining return mixed
2021-04-11 19:25:56 +02:00
Nicolas Grekas
4e904ec108 bug #40740 [Cache][FrameworkBundle] Fix logging for TagAwareAdapter (fancyweb)
This PR was merged into the 4.4 branch.

Discussion
----------

[Cache][FrameworkBundle] Fix logging for TagAwareAdapter

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | https://github.com/symfony/symfony/issues/40108
| License       | MIT
| Doc PR        | -

Commits
-------

6b0beca36f [Cache] [FrameworkBundle] Fix logging for TagAwareAdapter
2021-04-11 19:20:11 +02:00
Thomas Calvet
97a43e1dab [HttpClient][PHPDoc] Fix 2 remaining return mixed 2021-04-11 19:17:27 +02:00
Thomas Calvet
6b0beca36f [Cache] [FrameworkBundle] Fix logging for TagAwareAdapter 2021-04-11 19:05:34 +02:00
Nicolas Grekas
7ce1dda109 bug #40755 [Routing] Better inline requirements and defaults parsing (Foxprodev)
This PR was merged into the 4.4 branch.

Discussion
----------

[Routing] Better inline requirements and defaults parsing

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #40749 #40701
| License       | MIT
| Doc PR        |

Remove `!` symbol from requirements and defaults array keys in Route class. Leave `!` symbol in Route compiled path for correct token creation.
**The only restriction I found:**
Important variable can't get default value, only in UrlGenerator.
As mentioned in
0f96ac7484/src/Symfony/Component/Routing/RouteCompiler.php (L217)
they are not optional

Feel free to help me with some advice. Thank you in advance

Commits
-------

2a8c94a871 [Route] Better inline requirements and defaults parsing
2021-04-11 15:11:13 +02:00
Foxprodev
2a8c94a871 [Route] Better inline requirements and defaults parsing
Remove ! symbol from requirements and defaults array keys in Route class. Leave ! symbol in Route compiled path for correct token creation
Added some inline route settings tests
2021-04-11 14:59:39 +02:00
Nicolas Grekas
4a8ea4094f bug #40754 [PhpUnitBridge] Fix phpunit symlink on Windows (johnstevenson)
This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] Fix phpunit symlink on Windows

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

If the symlink to `.phpunit/phpunit` already exists, unlink is called to remove it. But this fails on Windows (because it is a directory and requires `rmdir`), which in turn causes the subsequent `symlink` call to fail (because it already exists).

Additionally, creating symlinks on Windows requires Administrator permissions (generally), so `.phpunit/phpunit` can never be created for ordinary Users.

This PR uses a junction instead of a symlink on Windows. It also fixes some issues with stderror output and adds some argument escaping.

Commits
-------

ff8093246b [PhpUnitBridge] Fix phpunit symlink on Windows
2021-04-11 14:54:19 +02:00
Nicolas Grekas
03ef116496 minor #40760 Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest (StefanoCappellini)
This PR was submitted for the 5.x branch but it was merged into the 4.4 branch instead.

Discussion
----------

Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | None
| License       | MIT

This PR simplifies a condition and removes unused code (AFAIK coming from  #38894)).

Commits
-------

d344b8d6cb Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest
2021-04-11 14:47:43 +02:00
StefanoCappellini
d344b8d6cb Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest 2021-04-11 14:47:37 +02:00
Robin Chalas
b40eac2e78 feature #40145 [Security] Rework the remember me system (wouterj)
This PR was squashed before being merged into the 5.3-dev branch.

Discussion
----------

[Security] Rework the remember me system

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fixes part of #39308
| License       | MIT
| Doc PR        | tbd

As I said in #39308, I want to change the remember me system in Symfony 5.3. The remember me system has a couple big "problems":

1. **It's hardwired into some Security classes** like `ContextListener`. The `RememberMeFactory` adds a `setRememberMe()` method call to the DI config and the context listener calls methods on this. This is very coupled, instead of the decoupled nature of the rest of security.
2. **Conditional conditions are combined with cookie creation in one class**. This is especially hard in e.g. 2FA (where setting the cookie should be done after 2FA is completed, which is currently near impossible as it's directly bound to the conditional of being called after logging in).

The changes
---

* The first commits harden the current functional test suite of remember me, to avoid breaking it.
* I discovered a lot of similarity between remember me tokens and login links. That's why I've extracted the shared logic into a generic `SignatureHasher` in the 3rd commit.
* I then remodelled `RememberMeAuthenticator` to the login link system, which I think improves a lot and at least improves problem (2) - as the conditionals (`RememberMeAuthenticator`) is split from the cookie creation (`RememberMeHandlerInterface`).
* Finally, I added a new event (`TokenDeauthenticatedEvent`) to the `ContextListener` to avoid direct coupling - solving problem (1).

This removes any usage of remember me services, which can be deprecated along with the rest of the security system.

Usage
---

As with the authenticator manager: **Nothing changes in the configuration**

Usage of persistent token providers has been improved. First, configuration is provided (setting up services is no longer needed):
```yaml
# before
services:
    Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider:
        autowire: true

security:
    firewalls:
        main:
            remember_me:
                # ...
                token_provider: 'Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider'

# after
security:
    firewalls:
        main:
            remember_me:
                # ...
                token_provider:
                    doctrine: true
```

Furthermore, a schema listener is created. Whenever the doctrine token provider is used, `make:migration`/`doctrine:schema:update` will automatically create the required table.

Some advanced usage of Remember me is also improved a lot (there is no real "before" here, consider looking at scheb/2fa to get an idea of the before). A few use-cases I took into account:

* If you ever need to **programmatically create a remember me cookie**, you can autowire `RememberMeHandlerInterface` and use `createRememberMeCookie($user)`. This will make sure the remember me cookie is set on the final response (using the `ResponseListener`)
* The `RememberMeListener` previously was responsible for both determining if a cookie must be set and setting the cookie. This is now split in 2 listeners (checking is done by `RememberMeConditionsListener`). If `RememberMeBadge` is enabled, the cookie is set and otherwise it isn't. This allows e.g. SchebTwoFactorBundle to create a listener that catches whether remember me was requested, but suppress it until the 2nd factor is completed.

Todo
---

* [x] Update UPGRADE and CHANGELOG
* [x] Show before/after examples
* [x] Investigate the conditional event registering of `ContextListener`. This forces to inject both the firewall and the global event dispatcher at the moment.
* Make sure old remember me tokens still function. As remember me tokens are long lived, we may need to provide backwards compatibility for at least Symfony 6.x. **Update: it was decided to not include this for now: https://github.com/symfony/symfony/pull/40145#issuecomment-785819607**

cc `@scheb` `@weaverryan` as you both initiated this PR by sharing the problems with the current design.

Commits
-------

15670419d4 [Security] Rework the remember me system
2021-04-11 14:47:25 +02:00
Wouter de Jong
15670419d4 [Security] Rework the remember me system 2021-04-11 14:47:19 +02:00
Nicolas Grekas
1e4241175f minor #40766 [Notifier] [Bridge] Remove hidden dependency on HttpFoundation (Nyholm)
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Notifier] [Bridge] Remove hidden dependency on HttpFoundation

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

We dont need HttpFoundation to give us this constant. HttpFoundation is also missing from composer.json

Commits
-------

d37f158a88 [Notifier][Bridge] Remove hidden dependency on HttpFoundation
2021-04-11 14:44:57 +02:00
Nyholm
d37f158a88
[Notifier][Bridge] Remove hidden dependency on HttpFoundation 2021-04-11 10:41:01 +02:00
Jérémy Derussé
9ad3720efc
[security] NullToken signature 2021-04-10 12:08:01 +02:00
Pavel Kirpitsov
5fa7ff9541 [Messenger] Added X-Ray trace header support to the SQS transport 2021-04-10 00:55:17 +03:00
John Stevenson
ff8093246b [PhpUnitBridge] Fix phpunit symlink on Windows 2021-04-09 15:31:01 +01:00