Skip to content

[SecurityBundle] Move Anonymous DI integration to new AnonymousFactory #33503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2019

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Sep 8, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR n/a

For some reason, all security authentication providers/listeners have a SecurityFactory that adds configuration and registers the necessary services, except from anonymous security. I'm not sure why that has not been done. The only thing I can think of is making sure it is added to the end.

I've added a new "internal" factory position, to make sure it is always the last registered provider and moved everything to a new AnonymousFactory.

Nothing changes on the usage side, but it makes internal code a bit easier to understand and makes sure we don't break anything while refactoring the SecurityExtension in the future.

@wouterj wouterj changed the title [Security] Move Anonymous DI integration to new AnonymousFactory [SecurityBundle] Move Anonymous DI integration to new AnonymousFactory Sep 8, 2019
@wouterj wouterj force-pushed the security/add-anonymous-factory branch 2 times, most recently from e152c11 to 4be4d94 Compare September 8, 2019 14:04
@wouterj wouterj force-pushed the security/add-anonymous-factory branch from 4be4d94 to 0da2761 Compare September 8, 2019 14:32
@nicolas-grekas nicolas-grekas added this to the next milestone Sep 8, 2019
Copy link
Contributor

@linaori linaori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the tests are still green after changing this, so feature wise it indeed doesn't change anything. 👍 from my side as this will indeed improve the internal code and no longer handles anonymous as an exceptional case.

One question though, what if after this factory, a custom factory is added?

@wouterj
Copy link
Member Author

wouterj commented Sep 10, 2019

One question though, what if after this factory, a custom factory is added?

Given no listener/provider from the earlier factories could authenticate the request, there are 2 cases: If anonymous is enabled in the firewall, the listener/provider of that factory would not be called (anonymous is able to authenticate any request). If anonymous is disabled, it'll just be called at the end.

@fabpot
Copy link
Member

fabpot commented Sep 11, 2019

Thank you @wouterj.

fabpot added a commit that referenced this pull request Sep 11, 2019
…AnonymousFactory (wouterj)

This PR was merged into the 4.4 branch.

Discussion
----------

[SecurityBundle] Move Anonymous DI integration to new AnonymousFactory

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | n/a

For some reason, all security authentication providers/listeners have a `SecurityFactory` that adds configuration and registers the necessary services, except from anonymous security. I'm not sure why that has not been done. The only thing I can think of is making sure it is added to the end.

I've added a new "internal" factory position, to make sure it is always the last registered provider and moved everything to a new `AnonymousFactory`.

Nothing changes on the usage side, but it makes internal code a bit easier to understand and makes sure we don't break anything while refactoring the `SecurityExtension` in the future.

Commits
-------

0da2761 Move Anonymous config to a SecurityFactory
@fabpot fabpot merged commit 0da2761 into symfony:4.4 Sep 11, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
@wouterj wouterj deleted the security/add-anonymous-factory branch November 24, 2019 16:30
fabpot added a commit that referenced this pull request Nov 25, 2019
…nymous listener (chalasr)

This PR was merged into the 4.4 branch.

Discussion
----------

[SecurityBundle] Don't require a user provider for the anonymous listener

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

Forgotten when adding the AnonymousFactory in #33503

Commits
-------

0950cfb [SecurityBundle] Don't require a user provider for the anonymous listener
martijnboers added a commit to martijnboers/symfony that referenced this pull request Dec 3, 2019
chalasr pushed a commit that referenced this pull request Dec 3, 2019
…martijnboers)

This PR was merged into the 4.4 branch.

Discussion
----------

[SecurityBundle] Use config variable in AnonymousFactory

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

It looks like the `AnonymousFactory` was copied incorrectly in #33503 as it uses the old `$firewall` variable available in `SecurityExtension.php`. Changing this to `$config` yields the desired results

Commits
-------

8d850d2 When set, get secret from config variable
symfony-splitter pushed a commit to symfony/security-bundle that referenced this pull request Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants