Commit Graph

51185 Commits

Author SHA1 Message Date
Lars Strojny
a2508ac3e7 [Cache] Allow ISO 8601 time intervals to specify default lifetime 2020-10-05 15:19:55 +02:00
Nicolas Grekas
5a3e1db9ce minor #38413 [HttpClient] change piority of RetryableHttpClient (jderusse)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[HttpClient] change piority of RetryableHttpClient

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

This make the RetryableHttpClient decorated the TraceableHttpClient.
User will be able to check content of each sub-request

Commits
-------

9568d437f9 Change priority of RetryableHttpClient
2020-10-05 10:23:57 +02:00
Jérémy Derussé
9568d437f9
Change priority of RetryableHttpClient 2020-10-05 10:04:53 +02:00
Fabien Potencier
cb3e18a925 Merge branch '5.1'
* 5.1:
  Change test
2020-10-04 18:36:01 +02:00
Fabien Potencier
5e808b59ec Merge branch '4.4' into 5.1
* 4.4:
  Change test
2020-10-04 18:35:53 +02:00
Fabien Potencier
20969e604b Merge branch '3.4' into 4.4
* 3.4:
  Change test
2020-10-04 18:35:43 +02:00
Fabien Potencier
bfcf65f61c Change test 2020-10-04 18:34:28 +02:00
Fabien Potencier
57ad83e7e1 Merge branch '5.1'
* 5.1:
  Added Stopwatch example to the README
  Bump Symfony version to 5.1.8
  Update VERSION for 5.1.7
  Update CHANGELOG for 5.1.7
  Bump Symfony version to 4.4.16
  Update VERSION for 4.4.15
  Update CHANGELOG for 4.4.15
2020-10-04 18:29:51 +02:00
Fabien Potencier
84bec1df2d Merge branch '4.4' into 5.1
* 4.4:
  Added Stopwatch example to the README
  Bump Symfony version to 4.4.16
  Update VERSION for 4.4.15
  Update CHANGELOG for 4.4.15
2020-10-04 18:29:28 +02:00
Fabien Potencier
619509e3c3 minor #38409 [Stopwatch] Added example to the README (wouterj)
This PR was merged into the 4.4 branch.

Discussion
----------

[Stopwatch] Added example to the README

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

Commits
-------

e2461c90d2 Added Stopwatch example to the README
2020-10-04 17:43:30 +02:00
Wouter de Jong
e2461c90d2 Added Stopwatch example to the README 2020-10-04 14:01:13 +02:00
Fabien Potencier
c91ad1239f feature #38382 [Validator] Use comparison constraints as attributes (derrabus)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[Validator] Use comparison constraints as attributes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | #38096
| License       | MIT
| Doc PR        | TODO, let's add it to symfony/symfony-docs#14305

This PR enables all child classes of `AbstractComparison` to be used as attributes.

Some of those constraints used a trait called `NumberConstraintTrait` for a shared implementation. After my changes, that trait did not fit well anymore, so I've added a new `ZeroComparisonConstraintTrait` as a replacement. Although I don't expect `NumberConstraintTrait` to provide much value outside of the Symfony codebase, I think we cannot safely change it because it was not labelled as `@internal`. This is basically why I went for the deprecation.

Commits
-------

b5bdf8288f [Validator] Use comparison constraints as attributes.
2020-10-04 10:54:16 +02:00
Fabien Potencier
dfcde5b409 feature #38369 [HttpFoundation] Expired cookies string representation consistency & tests (iquito)
This PR was squashed before being merged into the 5.2-dev branch.

Discussion
----------

[HttpFoundation] Expired cookies string representation consistency & tests

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| License       | MIT

These changes add consistent behavior when converting expired cookies back and forth from string representation into `Symfony\Component\HttpFoundation\Cookie` instances in `Cookie::fromString`:

- When `Max-Age` is zero and `expires` is in the past, the `expires` date is kept as is (previous behavior: `expires` is overwritten with current timestamp because it is reset to current timestamp + `Max-Age`)
- When `Max-Age` is zero and `expires` is in the future, expires is reset to current timestamp, as `Max-Age` is the preferred "source of truth" (same as previous behavior)
- Add tests for how the Cookie class handles `Max-Age` in a cookie string and how `expires` and `Max-Age` interact
- Extract helper function `expiresTimestamp` so converting to a unix timestamp can be reused in `Cookie::fromString`

This is more a new feature than a bug fix in my mind, therefore I would include it in 5.1+.

Commits
-------

4f5d5eceb0 [HttpFoundation] Expired cookies string representation consistency & tests
2020-10-04 10:45:41 +02:00
Andreas
4f5d5eceb0 [HttpFoundation] Expired cookies string representation consistency & tests 2020-10-04 10:45:35 +02:00
Fabien Potencier
383d73ed60 feature #38407 [Mime] Prefer .jpg instead of .jpeg (fabpot)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[Mime] Prefer .jpg instead of .jpeg

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

Commits
-------

89adb2133b [Mime] Prefer .jpg instead of .jpeg
2020-10-04 10:37:55 +02:00
Fabien Potencier
89adb2133b [Mime] Prefer .jpg instead of .jpeg 2020-10-04 10:36:21 +02:00
Fabien Potencier
a6103adcf9 Bump Symfony version to 5.1.8 2020-10-04 10:00:52 +02:00
Fabien Potencier
ccdb433279
Merge pull request #38406 from fabpot/release-5.1.7
released v5.1.7
2020-10-04 09:57:45 +02:00
Fabien Potencier
1d18312db6 Update VERSION for 5.1.7 2020-10-04 09:57:28 +02:00
Fabien Potencier
a2b45cc3bc Update CHANGELOG for 5.1.7 2020-10-04 09:57:11 +02:00
Fabien Potencier
8cb3387ce2 Bump Symfony version to 4.4.16 2020-10-04 09:55:30 +02:00
Fabien Potencier
d6cc026bc1
Merge pull request #38405 from fabpot/release-4.4.15
released v4.4.15
2020-10-04 09:48:33 +02:00
Fabien Potencier
e42cfee451 Update VERSION for 4.4.15 2020-10-04 09:48:13 +02:00
Fabien Potencier
edb5fed4bb feature #36479 [Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler (jschaedl)
This PR was squashed before being merged into the 5.2-dev branch.

Discussion
----------

[Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | - <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | - <!-- required for new features -->

This is the first iteration of adding a profiler panel for the new Notifier component:

WebProfiler Toolbar:
![Screenshot 2020-10-02 at 10 26 35](https://user-images.githubusercontent.com/1880467/94903474-28bece00-049a-11eb-945c-d6ce047b35e8.png)

WebProfiler Notifier Panel:

![Screenshot 2020-10-02 at 10 28 19](https://user-images.githubusercontent.com/1880467/94903594-5277f500-049a-11eb-8c1e-27e6ec87a51c.png)
![Screenshot 2020-10-02 at 10 28 29](https://user-images.githubusercontent.com/1880467/94903591-51df5e80-049a-11eb-935a-9ba130ef69f0.png)
![Screenshot 2020-10-02 at 10 28 35](https://user-images.githubusercontent.com/1880467/94903589-5146c800-049a-11eb-8a69-28d362ef6640.png)
![Screenshot 2020-10-02 at 10 28 42](https://user-images.githubusercontent.com/1880467/94903586-50159b00-049a-11eb-97bd-382a823087a6.png)

An example project can to test the new profiler panel can be found here: https://github.com/jschaedl/notifier-profiler-integration

Commits
-------

f39e74ba9f [Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler
2020-10-04 09:43:38 +02:00
Jan Schädlich
f39e74ba9f [Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler 2020-10-04 09:43:31 +02:00
Fabien Potencier
d88dd13e43 Update CHANGELOG for 4.4.15 2020-10-04 09:20:11 +02:00
Fabien Potencier
f8212cc9e3 Merge branch '5.1'
* 5.1:
  Update security.he.xlf
2020-10-04 09:09:29 +02:00
Fabien Potencier
936c6afdf0 Merge branch '4.4' into 5.1
* 4.4:
  Update security.he.xlf
2020-10-04 09:09:21 +02:00
Fabien Potencier
9c1b6fc985 Merge branch '3.4' into 4.4
* 3.4:
  Update security.he.xlf
2020-10-04 09:09:09 +02:00
Fabien Potencier
62a76ba871 Merge branch '5.1'
* 5.1:
  Handle consecutive supports() calls in the RememberMeAuthenticator
2020-10-04 09:09:00 +02:00
Fabien Potencier
3b524f6d70 feature #38395 [lock] Prevent user serializing the key when store does not support it. (jderusse)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[lock] Prevent user serializing the key when store does not support it.

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

Some store relies on connection with the running process. ie. kernel relaease flock/semaphore, or zookeeper neeeds a connection to the database.

When the users tries to serialize the key to send it to another process, they are not aware that they lose the lock.

This PR throws an exception in that situation.

Commits
-------

1ec0630262 Prevent user serializing the key
2020-10-04 09:08:28 +02:00
Fabien Potencier
c6a747d64b minor #38403 Remove array return type from Request::toArray() (GrahamCampbell)
This PR was merged into the 5.2-dev branch.

Discussion
----------

Remove array return type from Request::toArray()

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

Laravel already extends Symfony's `Request` class and defines it's own `toArray` method. https://github.com/symfony/symfony/pull/38224 added a new `toArray` method to this class with a different signature to the one that is in Laravel, causing fatal errors (https://github.com/laravel/framework/issues/34660). I think the best course of action here is to remove the return type for now, and only add it in Symfony 6. This will allow Symfony 6.0 and Laravel 11 to synchronize adding the return type.

Older versions of Laravel can't just change their signature to add an array return type to them, because that would be a breaking change for Laravel users extending Laravel's request class. I'm thinking, in particular, API packages and the like, or just straight up application code.

Commits
-------

8b291a49a6 Remove array return type from Request::toArray()
2020-10-04 09:07:32 +02:00
Fabien Potencier
7db7dcc431 minor #38402 Update security.he.xlf (ben29)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead.

Discussion
----------

Update security.he.xlf

Update Hebrew translation

Commits
-------

8d4c2f052d Update security.he.xlf
2020-10-04 09:06:41 +02:00
Ben Hakim
8d4c2f052d Update security.he.xlf 2020-10-04 09:06:34 +02:00
Fabien Potencier
b94fef4670 bug #38396 Handle consecutive supports() calls in the RememberMeAuthenticator (wouterj)
This PR was merged into the 5.1 branch.

Discussion
----------

Handle consecutive supports() calls in the RememberMeAuthenticator

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

If I read the issue correctly, the problem is not so much that `autoLogin()` is called in supports, but that it is called multiple times in the same request (in lazy firewalls). This is fixed by this issue.

@qurben or @fancyweb do you have an application with this error, and can you please test the patch in this PR? Please let me know if this actually fixed the issue. (if you can't, I'll create a small demo app to test this one)

Commits
-------

e0d1867b54 Handle consecutive supports() calls in the RememberMeAuthenticator
2020-10-04 09:05:27 +02:00
Fabien Potencier
200392e473 minor #38404 [HttpClient] Minor fix of type and message in ExponentialBackOff (bohanyang)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[HttpClient] Minor fix of type and message in ExponentialBackOff

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

Make the type consistent and fix an error message

Commits
-------

6149a0c04b [HttpClient] Minor fix of type and message in ExponentialBackOff
2020-10-04 09:03:11 +02:00
Fabien Potencier
42d86cf2af minor #38397 [Console] Remove "php" invokation from help messages. (rodrigoaguilera)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[Console] Remove "php" invokation from help messages.

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| License       | MIT

Discusstion started here:
https://github.com/symfony/symfony/pull/38349

I was a bit puzzled to find that the help for the list and help commands suggests that you call the console application by prefixing it with `php myconsoleapp`.

As suggested in the PR above I am removing the `php ` prefix from the help.

I am providing a script with a shebang like the first example suggested in the following link:
https://symfony.com/doc/current/components/console.html
Eventually I want to distribute my console app as docker image so there is no need for php installed or the users even knowing is written in php.
The script name is easy to override by just setting a different value to `$_SERVER['PHP_SELF']` but this php prefix is hardcoded into the help strings for the the two default commands available.

Slightly related to #38347 as I am trying to improve the console help output.

Commits
-------

e036c30e7a [Console] Remove "php" invokation from help messages.
2020-10-04 09:01:38 +02:00
Bohan Yang
6149a0c04b [HttpClient] Minor fix of type and message in ExponentialBackOff 2020-10-04 10:23:35 +08:00
Graham Campbell
8b291a49a6
Remove array return type from Request::toArray() 2020-10-03 23:39:59 +01:00
Rodrigo Aguilera
e036c30e7a [Console] Remove "php" invokation from help messages. 2020-10-03 16:00:31 +02:00
Fabien Potencier
8fa6b3625b Merge branch '5.1'
* 5.1:
  Fix tests
  [Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter
  [Serializer][Minor] Fix exception message
2020-10-03 15:58:25 +02:00
Fabien Potencier
40bc14ab78 Merge branch '4.4' into 5.1
* 4.4:
  Fix tests
  [Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter
  [Serializer][Minor] Fix exception message
2020-10-03 15:58:17 +02:00
Wouter de Jong
e0d1867b54 Handle consecutive supports() calls in the RememberMeAuthenticator 2020-10-03 15:02:03 +02:00
Jérémy Derussé
1ec0630262
Prevent user serializing the key 2020-10-03 14:03:42 +02:00
Fabien Potencier
2be67879b9 feature #38307 [Form] Implement Twig helpers to get field variables (tgalopin)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[Form] Implement Twig helpers to get field variables

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/14308

Designing Symfony Forms has always been difficult, especially for developers not comfortable with Symfony or Twig. The reason behind this difficulty is that the current `form_*` helper functions, while providing a way to quickly render a form, are hiding the generated HTML behind a notation specific to Symfony.

HTML standards introduced many new attributes since the Form component was created, from new constraints to how should inputs be displayed, treated by screen readers, etc.

I propose to introduce a series of new Twig functions to help create more flexible forms without the hurdle of having to use `form_*` functions. I called these methods `field_*` because they aim at rendering only the tiny bits of strings necessary to map forms to the Symfony backend.

The functions introduced are:

* `field_name` returns the name of the given field
* `field_value` returns the current value of the given field
* `field_label` returns the label of the given field, translated if possible
* `field_help` returns the help of the given field, translated if possible
* `field_errors` returns an iterator of strings for each of the errors of the given field
* `field_choices` returns an iterator of choices (the structure depending on whether the field uses or doesn't use optgroup) with translated labels if possible as keys and values as values

A quick example of usage of these functions could be the following:

``` twig
<input
    name="{{ field_name(form.username) }}"
    value="{{ field_value(form.username) }}"
    placeholder="{{ field_label(form.username) }}"
    class="form-control"
/>

<select name="{{ field_name(form.country) }}" class="form-control">
    <option value="">{{ field_label(form.country) }}</option>

    {% for label, value in field_choices(form.country) %}
        <option value="{{ value }}">{{ label }}</option>
    {% endfor %}
</select>

<select name="{{ field_name(form.stockStatus) }}" class="form-control">
    <option value="">{{ field_label(form.stockStatus) }}</option>

    {% for groupLabel, groupChoices in field_choices(form.stockStatus) %}
        <optgroup label="{{ groupLabel }}">
            {% for label, value in groupChoices %}
                <option value="{{ value }}">{{ label }}</option>
            {% endfor %}
        </optgroup>
    {% endfor %}
</select>

{% for error in field_errors(form.country) %}
    <div class="text-danger mb-2">
        {{ error }}
    </div>
{% endfor %}
```

There are several advantages to using these functions instead of their `form_*` equivalents:

* they are much easier to use for developers not knowing Symfony: they rely on native HTML with bits of logic inside, instead of relying on specific tools needing to be configured to display proper HTML
* they allow for better integration with CSS frameworks or Javascript libraries as adding a new HTML attribute is trivial (no need to look at the documentation)
* they are easier to use in contexts where one would like to customize the rendering of a input in details: having the label as placeholder, displaying a select empty field, ...

The `form_*` functions are still usable of course, but I'd argue this technique is actually easier to read and understand.

Commits
-------

3941d70928 [Form] Implement Twig helpers to get field variables
2020-10-03 11:48:50 +02:00
Fabien Potencier
6a79f3e06f Fix tests 2020-10-03 08:31:32 +02:00
Fabien Potencier
35e04d9136 bug #36291 [Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter (Jontsa)
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter

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

Updates `Symfony\Component\Lock\Store\StoreFactory` to accept same DSN syntax as `Symfony\Component\Cache\Adapter\AbstractAdapter` which is used to create Redis class instance.

Commits
-------

4ebbe3d86b [Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter
2020-10-03 08:30:09 +02:00
Joni Halme
4ebbe3d86b [Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter 2020-10-03 08:30:00 +02:00
Fabien Potencier
534466d1cf feature #38177 [Security] Magic login link authentication (weaverryan)
This PR was squashed before being merged into the 5.2-dev branch.

Discussion
----------

[Security] Magic login link authentication

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

Hi!

This adds a Slack-style "magic link" login authenticator to the new login system: (A) enter your email into a form, (B) receive an email with a link in it (C) click that link and you are authenticated!

For most users, implementing this would require:

A) Create a [controller](https://github.com/weaverryan/symfony-magic-login-link-example/blob/master/src/Controller/MagicLinkLoginController.php) with the "enter your email" form and a route for the "check" functionality (similar to `form_login`)
B) Activate in `security.yaml`:

```yml
security:
    enable_authenticator_manager: true
    # ...
    firewalls:
        # ...
        main:
            # ...
            login_link:
                check_route: 'magic_link_verify'
                # this is an important and powerful option
                # An array of properties on your User that are used to sign the link.
                # If any of these change, all existing links will become invalid
                # tl;dr If you want the modification of ANY field to invalidate ALL existing magic links immediately,
                # then you can add it to this list. You could even add a "lastLoginLinkSentAt" to invalid
                # all existing login links when a new one is sent.
                signature_properties: [id, password, email]

                # optional - by default, links can be reused but have a 10 minute lifetime
                #max_uses: 3
                #used_link_cache: cache.app
```

Done! This will generate a URL that looks something like this:

> https://127.0.0.1:9033/login/verify?user=weaverryan@gmail.com&expires=1601342578&hash=YzE1ZDJlYjM3YTMyMjgwZDdkYzg2ZjFlMjZhN2E5ZWRmMzk3NjAxNjRjYThiMjMzNmIxYzAzYzQ4NmQ2Zjk4NA%3D%3D

We would implement a Maker command this config + login/controller. The implementation is done via a "signed URL" and an optional cache pool to "expire" links. The hash of the signed URL can contain any user fields you want, which give you a powerful mechanism to invalidate magic tokens on user data changes. See `signature_properties` above.

#### Security notes:

There is a LOT of variability about how secure these need to be:

* A) Many/most implementation only allow links to be used ONE time. That is *possible* with this implementation, but is not the *default*. You CAN add a `max_uses` config which stores the expired links in a cache so they cannot be re-used. However, to make this work, you need to do more work by adding some "page" between the link the users clicks and *actually* using the login link. Why? Because unless you do this, email clients may follow the link to "preview" it and will "consume" the link.

* B) Many implementations will invalidate all other login links for a user when a new one is created. We do *not* do that, but that IS possible (and we could even generate the code for it) by adding a `lastLoginLinkSentAt` field to `User` and including this in `signature_properties`.

* C) We *do* invalidate all links if the user's email address is changed (assuming the `email` is included in `signature_properties`, which it should be). You can also invalidate on password change or whatever you want.

* D) Some implementations add a "state" so that you can only use the link on the same device that created it. That is, in many cases, quite annoying. We do not currently support that, but we could in the future (and the user could add it themselves).

Thanks!

#### TODOS:

* [x] A) more tests: functional (?) traits
* [ ] B) documentation
* [ ] C) MakerBundle PR
* [ ] D) Make sure we have what we need to allow that "in between" page
* [ ] E) Create a new cache pool instead of relying on cache.app?

Commits
-------

a8afe109d8 [Security] Magic login link authentication
2020-10-03 08:23:42 +02:00
Ryan Weaver
a8afe109d8 [Security] Magic login link authentication 2020-10-03 08:23:35 +02:00