Commit Graph

48628 Commits

Author SHA1 Message Date
Fabien Potencier
e36ea501a7 bug #36517 [Notifier] Fix error handling for Free mobile (fabpot)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Notifier] Fix error handling for Free mobile

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

Looks like the error handling code for Free mobile is a copy/paste from Twilio.

/cc @noniagriconomie

Commits
-------

6167ce4961 [Notifier] Fix error handling for Free mobile
2020-04-21 16:39:06 +02:00
Fabien Potencier
6167ce4961 [Notifier] Fix error handling for Free mobile 2020-04-21 16:08:57 +02:00
Fabien Potencier
2235be0864 feature #36516 [Notifier] Throw an exception when the Slack DSN is not valid (fabpot)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Notifier] Throw an exception when the Slack DSN is not valid

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

Improved errors in case of a DSN issue.
+ proper error for the Slack DSN when path is empty (will help catch when people haven't updated their Slack DSN for 5.1).

Commits
-------

6b1a64a642 [Notifier] Throw an exception when the Slack DSN is not valid
2020-04-21 15:48:22 +02:00
Fabien Potencier
5a9481784c Fix wrong version in composer.json 2020-04-21 15:43:00 +02:00
Fabien Potencier
a89a2a8893 Fix package name 2020-04-21 15:29:37 +02:00
Fabien Potencier
2a92dd3728 minor #36504 [Routing] Remove unused properties from the Route annotation (fancyweb)
This PR was merged into the 4.4 branch.

Discussion
----------

[Routing] Remove unused properties from the Route annotation

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

From what I see those properties are totally unused.

Commits
-------

9ac1c76fd5 [Routing] Remove unused properties from the Route annotation
2020-04-21 15:21:27 +02:00
Fabien Potencier
6b1a64a642 [Notifier] Throw an exception when the Slack DSN is not valid 2020-04-21 15:15:11 +02:00
Fabien Potencier
4cc605537f feature #35690 [Notifier] Add Free Mobile notifier (noniagriconomie)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Notifier] Add Free Mobile notifier

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Implements https://github.com/symfony/symfony-docs/pull/13025#pullrequestreview-352447344
| License       | MIT
| Doc PR        | Will document if accepted (see **Usage** below)

## Add a new notifier (SMS) with the French Free Mobile provider.

It is a **special notifier** as it **only send the SMS to the self user**,
but I think it can be **useful for notification alerting purposes** (the way I use it already, and plan to use it with the component)

---

**Provider doc:** (🇫🇷 sorry)

https://mobile.free.fr/moncompte/index.php?page=options

<img width="716" alt="1" src="https://user-images.githubusercontent.com/13205768/74357784-b55c3500-4dc0-11ea-95ba-19ded062e800.png">

<img width="431" alt="2" src="https://user-images.githubusercontent.com/13205768/74357786-b7be8f00-4dc0-11ea-837e-b922c20e9a2e.png">

---

**Usage:**

```
// .env file
FREEMOBILE_DSN=freemobile://LOGIN:PASSWORD@default?phone=PHONE
```

where:
 - `LOGIN` is your Free Mobile login
 - `PASSWORD` is the token displayed in the config panel
- `PHONE` is your Free Mobile phone number

```yaml
// config/packages/notifiers.yaml file
framework:
    notifier:
        texter_transports:
            freemobile: '%env(FREEMOBILE_DSN)%'
```

Then you can then use it like documented here https://symfony.com/doc/current/notifier/texters.html

ℹ️ As this is a special notifier, the `PHONE` provided inside the DSN mut be the same used [here](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Notifier/Message/SmsMessage.php#L31) for `$phone` value

---

Voilà!

Commits
-------

1b8709ee72 Add Free Mobile notifier
2020-04-21 15:13:45 +02:00
Fabien Potencier
1abdcbb205 feature #33558 [Security] AuthenticatorManager to make "authenticators" first-class security (wouterj)
This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[Security] AuthenticatorManager to make "authenticators" first-class security

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

The tl;dr
---

The old authentication listener + authentication provider system was replaced by a new "authenticator" system (similar to Guard authentication). All existing "auth systems" (e.g. `form_login` are now written as an "authenticator" in core).

Instead of each "authentication system" registering its own listener in the `Firewall`, there is now only one listener: `AuthenticatorManagerListener`

* `Firewall` -> executes `AuthenticatorManagerListener`
* `AuthenticatorManagerListener` -> calls `AuthenticatorManager`
* `AuthenticatorManager` -> calls each authenticator

This PR contains *no deprecations* and the "new system" is *marked as experimental*. This allows to continue to develop the new Security system during the 5.x release cycle without disturbing Symfony users. In 5.4, we can deprecate "old" Security and remove it completely in 6.0.

Important Decisions
---

* A) **The new authentication manager - `AuthenticatorManager` - now dispatches 3 important "hook" events**:

  * `VerifyAuthenticatorCredentialsEvent`: occurs at the point when a "password" needs to be checked. Allows us to centralize password checking, CSRF validation, password upgrading and the "user checker" logic.
  * `LoginSuccessEvent`: Dispatched after a successful authentication. E.g. used by remember me listener.
  * `LoginFailedEvent`: Dispatched after an unsuccessful authentication. Also used by remember me (and in theory could be used for login throttling).

* B) **`getCredentials()`, `getUser()` and `checkCredentials()` methods from old Guard are gone: their logic is centralized**.
   Authenticators now have an `authenticate(Request $request): PassportInterface` method. A passport contains the user object, the credentials and any other add-in Security badges (e.g. CSRF):

   ```php
   public function authenticate(Request $request): PassportInterface
   {
       return new Passport(
           $user,
           new PasswordCredentials($request->get('_password')),
           [
               new CsrfBadge($request->get('_token'))
           ]
       );
   }
   ```

   All badges (including the credentials) need to be resolved by listeners to `VerifyAuthenticatorCredentialsEvent`. There is build-in core support for the following badges/credentials:

   * `PasswordCredentials`: validated using the password encoder factory
   * `CustomCredentials`: allows a closure to do credentials checking
   * `CsrfTokenBadge`: automatic CSRF token verification
   * `PasswordUpgradeBadge`: enables password migration
   * `RememberMeBadge`: enables remember-me support for this authenticator

* C) **`AuthenticatorManager` contains all logic to authenticate**
  As authenticators always relate to HTTP, the `AuthenticatorManager` contains all logic to authenticate. It has three methods, the most important two are:

  * `authenticateRequest(Request $request): TokenInterface`: Doing what is previously done by a listener and an authentication provider;
  * `authenticateUser(UserInterface $user, AuthenticatorInterface $authenticator, Request $request, array $badges = [])` for manual login in e.g. a controller.

* D) **One AuthenticatorManager per firewall**
  In the old system, there was 1 authentication manager containing all providers and each firewall had a specific firewall listener. In the new system, each firewall has a specific authentication manager.

* E) **Pre-authentication tokens are dropped.**
  As everything is now handled inside `AuthenticatorManager` and everything is stored in the Security `Passport`, there was no need for a token anymore (removing lots of confusion about what information is inside the token).

  This change deprecates 2 authentication calls: one in `AuthorizationChecker#isGranted()` and one in `AccessListener`.  These seem now to be mis-used to reload users (e.g. re-authenticate the user after you change their roles). This (some "way" to change a user's roles *without* logging them out) needs to be "fixed"/added in another PR.

* F) **The remember me service now uses *all* user providers**
  Previously, only user providers of authentication providers listening on that firewall were used. This change is due to practical reasons and we don't think it is common to have 2 user providers supporting the same user instance. In any case, you can always explicitly configure the user provider under `remember_me`.

* G) **Auth Providers No Longer Clear the Token on Auth Failure**
  Previously, authentication providers did `$this->tokenStorage->setToken(null)` upon authentication failure. This is not yet implemented: our reasoning is that if you've authenticated successfully using e.g. the login form, why should you be logged out if you visit the same login form and enter wrong credentials?
  The pre-authenticated authenticators are an exception here, they do reset the token upon authentication failure, just like the old system.

* H) **CSRF Generator Service ID No Longer Configurable**
  The old Form login authentication provider allowed you to configure the CSRF generator service ID. This is no longer possible with the automated CSRF listener. This feature was introduced in the first CSRF commit and didn't get any updates ever since, so we don't think this feature is required. This could also be accomplished by checking CSRF manually in your authenticator, instead of using the automated check.

Future Considerations
---

* Remove Security sub-components: Move CSRF to `Symfony\Component\Csrf` (just like mime); Deprecated Guard; Put HTTP + Core as `symfony/security`. This means moving the new classes to `Symfony\Component\Security`

* Convert LDAP to the new system

* This is fixed (and merged) by #36243 <s>There is a need for some listeners to listen for events on one firewall, but not another (e.g. `RememberMeListener`). This is now fixed by checking the `$providerKey`. We thought it might be nice to introduce a feature to the event dispatcher:</s>

  * <s>Create one event dispatcher per firewall;</s>
  * <s>Extend the `kernel.event_subscriber` tag, so that you can optionally specify the dispatcher service ID (to allow listening on events for a specific dispatcher);</s>
  * <s>Add a listener that always also triggers the events on the main event dispatcher, in case you want a listener that is listening on all firewalls.</s>

* Drop the `AnonymousToken` and `AnonymousAuthenticator`: Anonymous authentication has never made much sense and complicates things (e.g. the user can be a string). For access control, an anonymous user has the same meaning as an un-authenticated one (`null`). This require changes in the `AccessListener` and `AuthorizationChecker` and probably also a new Security attribute (to replace `IS_AUTHENTICATED_ANONYMOUSLY`). Related issues: #34909, #30609

> **How to test**
> 1. Install the Symfony demo application (or any Symfony application)
> 2. Clone my Symfony fork (`git clone git@github.com:wouterj/symfony`) and checkout my branch (`git checkout security/deprecate-providers-listeners`)
> 3. Use the link utility to link my fork to the Symfony application: `/path/to/symfony-fork/link /path/to/project`
> 4. Enable the new system by setting `security.enable_authenticator_manager` to `true`

Commits
-------

b1e040f311 Rename providerKey to firewallName for more consistent naming
50224aa285 Introduce Passport & Badges to extend authenticators
9ea32c4ed3 Also use authentication failure/success handlers in FormLoginAuthenticator
0fe5083a3e Added JSON login authenticator
7ef6a7ab03 Use the firewall event dispatcher
95edc806a1 Added pre-authenticated authenticators (X.509 & REMOTE_USER)
f5e11e5f32 Reverted changes to the Guard component
ba3754a80f Differentiate between interactive and non-interactive authenticators
6b9d78d5e0 Added tests
59f49b20ca Rename AuthenticatingListener
60d396f2d1 Added automatically CSRF protected authenticators
bf1a452e94 Merge AuthenticatorManager and AuthenticatorHandler
44cc76fec2 Use one AuthenticatorManager per firewall
09bed16d3d Only load old manager if new system is disabled
ddf430fc1e Added remember me functionality
1c810d5d2a Added support for lazy firewalls
7859977324 Removed all mentions of 'guard' in the new system
999ec2795f Refactor to an event based authentication approach
b14a5e8c52 Moved new authenticator to the HTTP namespace
b923e4c4f6 Enabled remember me for the GuardManagerListener
873b949cf9 Mark new core authenticators as experimental
4c06236933 Fixes after testing in Demo application
fa4b3ec213 Implemented password migration for the new authenticators
5efa892395 Create a new core AuthenticatorInterface
50132587a1 Add provider key in PreAuthenticationGuardToken
526f75608b Added GuardManagerListener
a172bacaa6 Added FormLogin and Anonymous authenticators
9b7fddd10c Integrated GuardAuthenticationManager in the SecurityBundle
a6890dbcf0 Created HttpBasicAuthenticator and some Guard traits
c321f4d73a Created GuardAuthenticationManager to make Guard first-class Security
2020-04-21 14:44:22 +02:00
Fabien Potencier
01794d089c
Merge pull request #36514 from fabpot/notifier-still-experimental
[Notifier] Mark the component as experimental in 5.1
2020-04-21 13:53:17 +02:00
Fabien Potencier
bc85eb34c7 [Notifier] Mark the component as experimental in 5.1 2020-04-21 13:50:35 +02:00
Christian Flothmann
1452619a52 remove not needed BC layer 2020-04-21 09:24:21 +02:00
Christian Flothmann
eb26992f95 [#35368] add missing changelog entry 2020-04-21 08:45:37 +02:00
Thomas Calvet
76072c6424 [FrameworkBundle] Fix session.attribute_bag service definition 2020-04-20 18:42:48 +02:00
Thomas Calvet
9ac1c76fd5 [Routing] Remove unused properties from the Route annotation 2020-04-20 16:41:27 +02:00
noniagriconomie
1b8709ee72 Add Free Mobile notifier 2020-04-20 15:47:45 +02:00
Wouter de Jong
b1e040f311 Rename providerKey to firewallName for more consistent naming 2020-04-20 14:20:56 +02:00
Wouter de Jong
50224aa285 Introduce Passport & Badges to extend authenticators 2020-04-20 14:20:56 +02:00
Wouter de Jong
9ea32c4ed3 Also use authentication failure/success handlers in FormLoginAuthenticator 2020-04-20 14:20:56 +02:00
Wouter de Jong
0fe5083a3e Added JSON login authenticator 2020-04-20 14:20:56 +02:00
Wouter de Jong
7ef6a7ab03 Use the firewall event dispatcher 2020-04-20 14:20:56 +02:00
Wouter de Jong
95edc806a1 Added pre-authenticated authenticators (X.509 & REMOTE_USER) 2020-04-20 14:20:56 +02:00
Wouter de Jong
f5e11e5f32 Reverted changes to the Guard component 2020-04-20 14:20:56 +02:00
Wouter de Jong
ba3754a80f Differentiate between interactive and non-interactive authenticators 2020-04-20 14:20:56 +02:00
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