-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] Throw a meaningful exception when an undefined user provider is used inside a firewall #24114
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
@@ -332,6 +332,9 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a | |||
// Provider id (take the first registered provider if none defined) | |||
if (isset($firewall['provider'])) { | |||
$defaultProvider = $this->getUserProviderId($firewall['provider']); | |||
if (!in_array($defaultProvider, $providerIds, true)) { | |||
throw new InvalidConfigurationException(sprintf('User provider "%s" used for firewall "%s" does not exist.', $firewall['provider'], $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.
would that be more readable (similar below)?
Invalid firewall "%s": user provider "%s" not found.
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.
👍 should we use the very same message for the case where the provider is configured under a listener (handled below)? I think so
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.
LGTM
…inside a firewall
e58bed4
to
b884c66
Compare
Thank you @chalasr. |
…undefined user provider is used inside a firewall (chalasr) This PR was merged into the 3.4 branch. Discussion ---------- [SecurityBundle] Throw a meaningful exception when an undefined user provider is used inside a firewall | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Before > The service "security.authentication.manager" has a dependency on a non-existent service "security.user.provider.concrete.undefined_provider". After > Invalid firewall "main": user provider "undefined_provider" not found. Commits ------- b884c66 Throw a meaningful exception when an undefined user provider is used inside a firewall
I'm getting this error in project that worked with 2days old 3.4 What else has changed? |
Addon This PR is the culprit for the error. I've checked out 7dfb5aa which is one commit before this one was merged and everything works. This is the excerpt from the security.yml security:
encoders:
'Foo\Bundle\AccountBundle\Security\User':
algorithm: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
account:
id: account.security.user_provider
firewalls:
dev:
pattern: ^/(_(profiler|wdt|error|pomm))/
security: false
assets:
pattern: ^/(bundles|compiled)/
security: false
default:
pattern: .*
anonymous: true
user_checker: account.security.user_checker
logout:
path: /logout
target: /
invalidate_session: true
delete_cookies:
PHPSESSID: { path: null, domain: null }
form_login:
provider: account
login_path: account_security_login
check_path: account_security_check
username_parameter: 'login[username]'
password_parameter: 'login[password]'
remember_me:
secret: '%remember_me_key%'
lifetime: 2592000 # one month
path: /
domain: ~ # Defaults to the current domain from $_SERVER
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, role: [IS_AUTHENTICATED_FULLY,IS_AUTHENTICATED_REMEMBERED] } |
@chalasr ping |
@mvrhov I'm on it. |
Can you try #24132 and confirm it fixes it? Sorry for the inconvenience. |
Before
After