-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] Fix valid provider considered undefined #24132
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
Conversation
This still doesn't work.
but |
37f7ac0
to
33e2952
Compare
@mvrhov That should be better now (using |
c924b61
to
7fab70e
Compare
This seem to work now |
Thanks for confirming. Build failures unrelated. Ready |
any test case? |
796be6d
to
8bde4ae
Compare
now with tests :) |
This patch works fine for me, thank you. |
8bde4ae
to
6c61fd2
Compare
Rebased |
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall['provider'])); | ||
} | ||
$defaultProvider = $providerIds[$firewall['provider']]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldnt the str_replace
conversion happen here as well then?
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall[$key]['provider'])); | ||
} | ||
$userProvider = $this->getUserProviderId($firewall[$key]['provider']); | ||
$userProvider = $providerIds[$firewall[$key]['provider']]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -596,7 +596,7 @@ private function createUserProviders($config, ContainerBuilder $container) | |||
$providerIds = array(); | |||
foreach ($config['providers'] as $name => $provider) { | |||
$id = $this->createUserDaoProvider($name, $provider, $container); | |||
$providerIds[] = $id; | |||
$providerIds[$name] = $id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or normalize here :) (throw on duplicates?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, not sure about handling duplicates now
@@ -647,6 +647,11 @@ private function getUserProviderId($name) | |||
return 'security.user.provider.concrete.'.strtolower($name); | |||
} | |||
|
|||
private function isValidProviderName($providerName, array $allowedProviders) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps make this a getter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally removed
6c61fd2
to
13cda57
Compare
13cda57
to
efa4cb9
Compare
@@ -596,7 +596,7 @@ private function createUserProviders($config, ContainerBuilder $container) | |||
$providerIds = array(); | |||
foreach ($config['providers'] as $name => $provider) { | |||
$id = $this->createUserDaoProvider($name, $provider, $container); | |||
$providerIds[] = $id; | |||
$providerIds[str_replace('-', '_', $name)] = $id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by now i think the conversion should happen in getUserProviderId
actually 🤔 and simply make the check below $userProvider
. That would be more robust.
$userProvider = $this->getUserProviderId($firewall[$key]['provider']);
if (!isset($providerIds[$userProvider])) {
// throw
}
sorry :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about BC :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point is we create a different id 2 lines above by passing $name
as is to createUserDaoProvider
.. that looks weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get your point but yes, changing this is not fine regarding BC. Note also that when using a custom provider (specifying my_provider: { id: some_service }
), createUserDaoProvider
returns the some_service
id, it doesn't rely on getUserProviderId
. Let's avoid any behavior change here, not the right moment for that :)
I'm going to review this part of the extension in 2.7 once this merged, I believe there are some bugs. Right now, 3.4's security setup is broken, this covers all edge cases and makes it work again. I would like to quickly move on and polish afterwards if needed.
Btw, thanks for your review, it was useful actually.
IMO this should get merged ASAP as 3.4 is broken ATM. And then as @chalasr said it can be polished. |
Thank you @chalasr. |
…chalasr) This PR was merged into the 3.4 branch. Discussion ---------- [SecurityBundle] Fix valid provider considered undefined | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Silly mistake. Commits ------- efa4cb9 [SecurityBundle] Fix valid provider considered undefined
Silly mistake.