Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Make security.providers optional #26787

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
Apr 19, 2018
Merged

[Security] Make security.providers optional #26787

merged 1 commit into from
Apr 19, 2018

Conversation

MatTheCat
Copy link
Contributor

@MatTheCat MatTheCat commented Apr 4, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21998
License MIT

Don't really know if it's viable but I just hit #21998 so I would like to tackle this.

@MatTheCat
Copy link
Contributor Author

@chalasr @stof do you think this can cause issues?

Also I don't know how to provide a proper error message in case a provider is needed but none is configured.

@chalasr
Copy link
Member

chalasr commented Apr 6, 2018

Very complex topic, looks like you like them :) (#24805)

@weaverryan and me have this in mind for a while, the issue is that actually pretty much all security listeners are requiring a user provider for user loading/refreshment.
This misses new test case(s) (authentication with no configured provider), adding them will better answer your question.

@MatTheCat
Copy link
Contributor Author

MatTheCat commented Apr 6, 2018

Yes the way we'll authenticate our users makes me discover some edge cases!

the issue is that actually pretty much all security listeners are requiring a user provider for user loading/refreshment.

I don't understand how this is an issue?

@@ -166,8 +166,7 @@ public function testPerListenerProvider()
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage Not configuring explicitly the provider for the "http_basic" listener on "ambiguous" firewall is ambiguous as there is more than one registered provider.
* @expectedException \TypeError
Copy link
Member

Choose a reason for hiding this comment

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

getting a TypeError when not setting the provider isn't fine to me as this aims to make it optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree we need a proper error but I don't know when to throw it.

@MatTheCat
Copy link
Contributor Author

I created a dummy user provider whose sole purpose is to throw an exception, WDYT?

@weaverryan
Copy link
Member

Huh, a dummy provider is a really clever idea - it makes this very feasible (and sure, we could try to rip out the guts of the user provider system later... but that will be super hard and will probably never happen).

I like this!

@MatTheCat
Copy link
Contributor Author

Do we need a functional test where authentication is done without user provider?

@chalasr
Copy link
Member

chalasr commented Apr 12, 2018

@MatTheCat The config test added here should be enough

@MatTheCat
Copy link
Contributor Author

Are we good to go then or are some things missing?

@MatTheCat
Copy link
Contributor Author

Is it alright to let BadMethodCallExceptions empty?

throw new InvalidConfigurationException(sprintf(
'"%s" firewall requires a user provider but none was defined.',
$firewall
));
Copy link
Member

Choose a reason for hiding this comment

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

small thing: should be on one line.

$container->setDefinition(
$userProvider,
(new ChildDefinition('security.user.provider.missing'))->replaceArgument(0, $id)
);
Copy link
Member

Choose a reason for hiding this comment

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

CS fix: should be on one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh okay.

/**
* @param string $firewall the firewall missing a provider
*/
public function __construct($firewall)
Copy link
Member

Choose a reason for hiding this comment

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

string typehint

@fabpot
Copy link
Member

fabpot commented Apr 19, 2018

Thank you @MatTheCat.

@fabpot fabpot merged commit ee54bfa into symfony:master Apr 19, 2018
fabpot added a commit that referenced this pull request Apr 19, 2018
This PR was squashed before being merged into the 4.1-dev branch (closes #26787).

Discussion
----------

[Security] Make security.providers optional

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21998
| License       | MIT

Don't really know if it's viable but I just hit #21998 so I would like to tackle this.

Commits
-------

ee54bfa [Security] Make security.providers optional
@MatTheCat MatTheCat deleted the ticket_21998 branch April 19, 2018 19:46
@fabpot fabpot mentioned this pull request May 7, 2018
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.

6 participants