Commit Graph

48654 Commits

Author SHA1 Message Date
Wouter de Jong
6b9d78d5e0 Added tests 2020-04-20 14:20:56 +02:00
Wouter de Jong
59f49b20ca Rename AuthenticatingListener 2020-04-20 14:20:56 +02:00
Wouter de Jong
60d396f2d1 Added automatically CSRF protected authenticators 2020-04-20 14:20:56 +02:00
Wouter de Jong
bf1a452e94 Merge AuthenticatorManager and AuthenticatorHandler
The AuthenticatorManager now performs the whole authentication process. This
allows for manual authentication without duplicating or publicly exposing parts
of the process.
2020-04-20 14:20:56 +02:00
Wouter de Jong
44cc76fec2 Use one AuthenticatorManager per firewall 2020-04-20 14:20:56 +02:00
Wouter de Jong
09bed16d3d Only load old manager if new system is disabled 2020-04-20 14:20:56 +02:00
Wouter de Jong
ddf430fc1e Added remember me functionality 2020-04-20 14:20:56 +02:00
Wouter de Jong
1c810d5d2a Added support for lazy firewalls 2020-04-20 14:20:56 +02:00
Wouter de Jong
7859977324 Removed all mentions of 'guard' in the new system
This to remove confusion between the new system and Guard. When using the new
system, guard should not be installed. Guard did however influence the idea
behind the new system. Thus keeping the mentions of "guard" makes it confusing
to use the new system.
2020-04-20 14:20:56 +02:00
Wouter de Jong
999ec2795f Refactor to an event based authentication approach
This allows more flexibility for the authentication manager (to e.g. implement
login throttling, easier remember me, etc). It is also a known design pattern
in Symfony HttpKernel.
2020-04-20 14:20:56 +02:00
Wouter de Jong
b14a5e8c52 Moved new authenticator to the HTTP namespace
This removes the introduced dependency on Guard from core. It also allows an
easier migration path, as the complete Guard subcomponent can now be deprecated
later in the 5.x life.
2020-04-20 14:20:56 +02:00
Wouter de Jong
b923e4c4f6 Enabled remember me for the GuardManagerListener 2020-04-20 14:20:56 +02:00
Wouter de Jong
873b949cf9 Mark new core authenticators as experimental 2020-04-20 14:20:56 +02:00
Wouter de Jong
4c06236933 Fixes after testing in Demo application 2020-04-20 14:20:56 +02:00
Wouter de Jong
fa4b3ec213 Implemented password migration for the new authenticators 2020-04-20 14:20:55 +02:00
Wouter de Jong
5efa892395 Create a new core AuthenticatorInterface
This is an iteration on the AuthenticatorInterface of the Guard, to allow more
flexibility so it can be used as a real replaced of the authentication
providers and listeners.
2020-04-20 14:20:55 +02:00
Wouter de Jong
50132587a1 Add provider key in PreAuthenticationGuardToken
This is required to create the correct authenticated token in the
GuardAuthenticationManager.
2020-04-20 14:20:55 +02:00
Wouter de Jong
526f75608b Added GuardManagerListener
This replaces all individual authentication listeners when guard authentication
manager is enabled.
2020-04-20 14:20:55 +02:00
Wouter de Jong
a172bacaa6 Added FormLogin and Anonymous authenticators 2020-04-20 14:20:55 +02:00
Wouter J
9b7fddd10c Integrated GuardAuthenticationManager in the SecurityBundle 2020-04-20 14:20:55 +02:00
Wouter J
a6890dbcf0 Created HttpBasicAuthenticator and some Guard traits 2020-04-20 14:20:55 +02:00
Wouter J
c321f4d73a Created GuardAuthenticationManager to make Guard first-class Security 2020-04-20 14:20:55 +02:00
Thomas Calvet
9fd62f79fb [Routing] Add missing _locale requirements
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2020-04-20 14:17:53 +02:00
Fabien Potencier
e464954998 feature #36187 [Routing] Deal with hosts per locale (odolbeau)
This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[Routing] Deal with hosts per locale

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

Allow to define a different host for each locale in routing.

It's now possible to define this kind of configuration:
```yaml
controllers:
    resource: ../../src/Controller/
    type: annotation
    host:
        fr: www.example.fr
        en: www.example.com
```

It's still possible to define an unique host (`host: wwww.example.com`) and if a host is defined for a given route directly, it's not overridden.

To be done:
- [x] YamlLoader
- [x] XmlLoader
- [x] PhpLoader?
- [x] Documentation
- [x] Changelog

Commits
-------

4751a732f2 [Routing] Deal with hosts per locale
2020-04-20 10:51:57 +02:00
Olivier Dolbeau
4751a732f2 [Routing] Deal with hosts per locale 2020-04-20 10:51:50 +02:00
stoccc
4bda68a9a2
Update LdapBindAuthenticationProvider.php 2020-04-19 23:34:01 +02:00
Nicolas Grekas
95becc4078 bug #36457 [Cache] CacheItem with tag is never a hit after expired (alexander-schranz, nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[Cache] CacheItem with tag is never a hit after expired

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes/no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36458
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

It seems like a tag cacheItem is never a hit again. Not sure how fix this but the cache component is really hard to debug 🙈 .

It need to be somewhere generally as all TagAware caches are effected:

```
1) Symfony\Component\Cache\Tests\Adapter\FilesystemTagAwareAdapterTest::testRefreshAfterExpires

Failed asserting that false is true.

/home/travis/build/symfony/symfony/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php:194

2) Symfony\Component\Cache\Tests\Adapter\PredisTagAwareClusterAdapterTest::testRefreshAfterExpires

Failed asserting that true is false.

/home/travis/build/symfony/symfony/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php:183

3) Symfony\Component\Cache\Tests\Adapter\RedisTagAwareAdapterTest::testRefreshAfterExpires

Failed asserting that true is false.

/home/travis/build/symfony/symfony/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php:183

4) Symfony\Component\Cache\Tests\Adapter\RedisTagAwareClusterAdapterTest::testRefreshAfterExpires

Failed asserting that true is false.

/home/travis/build/symfony/symfony/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php:183
```

Commits
-------

d082eca7dd Add reproducer to for hit after update expire cacheItem
f815b011c3 [Cache] fix FilesystemTagAwareAdapter failing when a tag link preexists
2020-04-19 21:54:45 +02:00
Nicolas Grekas
8f9ff4f7a0 [Routing] fix CS 2020-04-19 19:10:00 +02:00
Nicolas Grekas
69b6c90330 Merge branch '5.0'
* 5.0:
  [HttpFoundation] workaround PHP bug in the session module
  [SecurityBundle] fix accepting env vars in remember-me configurations
  [Form] Fixed handling groups sequence validation
  [Mime] Ensure proper line-ending for SMIME
  [Cache] Avoid memory leak in TraceableAdapter::reset()
2020-04-18 22:50:29 +02:00
Nicolas Grekas
efbe752918 Merge branch '4.4' into 5.0
* 4.4:
  [HttpFoundation] workaround PHP bug in the session module
  [SecurityBundle] fix accepting env vars in remember-me configurations
  [Form] Fixed handling groups sequence validation
  [Cache] Avoid memory leak in TraceableAdapter::reset()
2020-04-18 22:50:06 +02:00
Nicolas Grekas
e0e3cf634e Merge branch '3.4' into 4.4
* 3.4:
  [HttpFoundation] workaround PHP bug in the session module
2020-04-18 22:40:08 +02:00
Nicolas Grekas
62565a1b66 bug #36490 [HttpFoundation] workaround PHP bug in the session module (nicolas-grekas)
This PR was merged into the 3.4 branch.

Discussion
----------

[HttpFoundation] workaround PHP bug in the session module

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

Current tests fail after https://github.com/php/php-src/pull/5305
Which itself is a patch for a bug in the session module.

This PR works around the issue in older versions of PHP and fixes the tests.

Commits
-------

0cbca19edc [HttpFoundation] workaround PHP bug in the session module
2020-04-18 22:39:13 +02:00
Nicolas Grekas
0cbca19edc [HttpFoundation] workaround PHP bug in the session module 2020-04-18 22:23:17 +02:00
Nicolas Grekas
23f5070696 minor #36485 [Security] Fixed broken master build (wouterj)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Security] Fixed broken master build

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

The build failures are caused by these lines (line 100 specically):

2460ca59af/src/Symfony/Component/Security/Http/Firewall/ContextListener.php (L97-L108)

Since #34363, `$request->cookies->get()` is typehinted as `string|null`. On Travis with PHP=7.4, this doc typehint is transformed into PHP return type: `get(): ?string`.

On tests, the session cookie is set to `true`. See #36118 for some background on why this is necessary.

There are a couple possible solutions:

1. Update the `InputBag::get()` PHPdoc to use `@return scalar|null`
2. Use `$request->cookie->all()[$session->getName()]` in `ContextListener`
3. Allow pre-configuring the session ID in `MockArraySessionStorage`.

I've implemented solution (1). The method is actually using `is_scalar()` to check if a deprecation notice should be triggered, so it is expected to return a scalar in Symfony 6.

_I've had to update the `DebugClassLoader` to not convert this to `get(): ?scalar`, as that doesn't exists in PHP. I'm not sure if my changes are correct (but they work)._

Commits
-------

94f47630ba Fixed fetching sessionId from InputBag
2020-04-18 21:15:36 +02:00
Wouter de Jong
94f47630ba Fixed fetching sessionId from InputBag 2020-04-18 20:51:12 +02:00
Alexander Schranz
d082eca7dd Add reproducer to for hit after update expire cacheItem 2020-04-18 16:28:10 +02:00
Nicolas Grekas
f815b011c3 [Cache] fix FilesystemTagAwareAdapter failing when a tag link preexists 2020-04-18 16:28:10 +02:00
Nicolas Grekas
80c5060401 Merge branch '3.4' into 4.4
* 3.4:
  [SecurityBundle] fix accepting env vars in remember-me configurations
  [Form] Fixed handling groups sequence validation
  [Cache] Avoid memory leak in TraceableAdapter::reset()
2020-04-18 14:50:46 +02:00
Nicolas Grekas
a347a84453 bug #36483 [SecurityBundle] fix accepting env vars in remember-me configurations (zek)
This PR was merged into the 3.4 branch.

Discussion
----------

[SecurityBundle] fix accepting env vars in remember-me configurations

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

As @wouterj explained we cannot use env variables after #35910 merged.

> Hmm, so I'm guessing this is what happens:
>
> * `lifetime` is now an `integerNode()`
> * For the Config component (which IIRC doesn't know anything about env variables), you're passing a string: `"%env(int:REMEMBER_ME_COOKIE_LIFETIME)%"`
> * This throws an error, although if it wouldn't, the DI component would sucessfully process the string into a integer before it's used by any PHP class.
>
> So we either make Config aware of environment variables (that's probably a huge feature) or we revert the `integerNode()` changes (as you suggested).
>
> @HeahDude am I mislooking something, or would reverting these 2 lines not result in much harm? (only a little less strict config processor)

Commits
-------

46c278316c [SecurityBundle] fix accepting env vars in remember-me configurations
2020-04-18 14:12:43 +02:00
Talha Zekeriya Durmuş
46c278316c [SecurityBundle] fix accepting env vars in remember-me configurations 2020-04-18 14:12:03 +02:00
Nicolas Grekas
0f1a5c452e bug #36343 [Form] Fixed handling groups sequence validation (HeahDude)
This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Fixed handling groups sequence validation

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | FIx https://github.com/symfony/symfony/issues/9939#issuecomment-607459505, Fix #35556
| License       | MIT
| Doc PR        | ~

This is not the same as the original issue fixed by #36245, that was reported in https://github.com/symfony/symfony/issues/9939#issuecomment-607459505.

The form also fails to cascade sequence validation properly because each nested field is validated against the sequence, and one can fail at a step independently from another which could failed in another step. I've added a lot of tests to ensure this is working properly and tested in a website skeleton too.

This PR aims to close #35556 which tries to fix the same issue but afterwards in its implementation as said in https://github.com/symfony/symfony/pull/35556#discussion_r379289230.

Commits
-------

dfb61c204c [Form] Fixed handling groups sequence validation
2020-04-18 14:07:22 +02:00
Jules Pietri
dfb61c204c
[Form] Fixed handling groups sequence validation 2020-04-18 13:27:37 +02:00
Fabien Potencier
2460ca59af feature #36464 [RedisMessengerBridge] Add a delete_after_ack option (Seldaek)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[RedisMessengerBridge] Add a delete_after_ack option

This allows Messenger to clean up processed messages from memory, avoiding a mem "leak" in redis

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | https://github.com/symfony/symfony/issues/33715
| License       | MIT
| Doc PR        | symfony/symfony-docs#... TODO - will pile it on to https://github.com/symfony/symfony-docs/pull/11869 as it kinda binds together and a bigger refactor of the docs here is much needed to avoid all these gotchas

Right now by default a redis transport for messenger will leak memory as all messages stay in redis forever. You can configure `stream_max_entries` to automatically trim to a max of X entries, but that means if you have big peaks in messages you might start losing messages which have not been processed.

This PR provides an alternative to that, by deleting message as they are processed. This is ideal as it avoids having to find the right number for `stream_max_entries` (do you want to risk losing data or use more memory than needed on average?). The only catch is that if you have multiple groups consuming the same stream, the first one processing a message will delete it, so other groups will not see it. For that reason `setup()` attempts to detect this and fails hard if it is misconfigured to prevent data loss.

Commits
-------

7c416a7173 [RedisMessengerBridge] Add a delete_after_ack option to automatically clean up processed messages from memory
2020-04-17 14:22:43 +02:00
Jordi Boggiano
7c416a7173
[RedisMessengerBridge] Add a delete_after_ack option to automatically clean up processed messages from memory 2020-04-17 08:23:45 +02:00
Fabien Potencier
67948a7ffb feature #36431 [Messenger] Add FIFO support to the SQS transport (cv65kr)
This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[Messenger] Add FIFO support to the SQS transport

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

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html

Commits
-------

37601753f1 [Messenger] Add FIFO support to the SQS transport
2020-04-17 05:34:16 +02:00
cv65kr
37601753f1 [Messenger] Add FIFO support to the SQS transport 2020-04-17 05:34:10 +02:00
Fabien Potencier
a85545f3e9 feature #36455 [Cache] Added context to log messages (Nyholm)
This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[Cache] Added context to log messages

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

In my application logs, I've got many entries like:

> Failed to save key "foobar" of type string.

I know it is related to the cache, But I dont know from what adapter. I use a chain of Array, Apcu and Redis. This PR adds some context to that log entry so I know which one of my cache adapter that fails.

Commits
-------

a4d9e0fc94 [Cache] Added context to log messages
2020-04-17 05:32:08 +02:00
Nyholm
a4d9e0fc94 [Cache] Added context to log messages 2020-04-17 05:31:59 +02:00
Fabien Potencier
6f81e03331 bug #36463 [Mime] Ensure proper line-ending for SMIME (sstok)
This PR was merged into the 5.0 branch.

Discussion
----------

[Mime] Ensure proper line-ending for SMIME

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

Commits
-------

5e3ccc2814 [Mime] Ensure proper line-ending for SMIME
2020-04-17 05:29:44 +02:00
Fabien Potencier
5369aff94f minor #36468 Use ExpectDeprecationTrait (fancyweb)
This PR was merged into the 5.1-dev branch.

Discussion
----------

Use ExpectDeprecationTrait

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

Commits
-------

08febef500 Use ExpectDeprecationTrait
2020-04-17 05:15:37 +02:00