Skip to content
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

FirewallConfig::customAuthenticators() method does not exist: cannot configure CustomAuthenticator via PHP #53987

Closed
arderyp opened this issue Feb 17, 2024 · 6 comments

Comments

@arderyp
Copy link
Contributor

arderyp commented Feb 17, 2024

Symfony version(s) affected

5.4.x

Description

The customAuthenticators() method does not exist on FirewallConfig. I can use yaml with custom_authenticator, but it seems impossible via PHP config using the FirewallConfig object. If you simply pass an array configuration to ContainerConfig with custom_authenticators it works, but there are benefits to using the config objects. I’ve tried the verbatim config from the documentation and it doesn’t work:

https://symfony.com/doc/5.x/security/custom_authenticator.html

I see no customAuthebticators() method anywhere in symfony core. The FirewallConfig I’m using is under var/cache/dev/Symfony/Config/

How to reproduce

Use the exact code from documentation

use App\Security\ApiKeyAuthenticator;
use Symfony\Config\SecurityConfig;

return static function (SecurityConfig $security) {
    $security->enableAuthenticatorManager(true);
    // ....

    $security->firewall('main')
        ->customAuthenticators([ApiKeyAuthenticator::class])
    ;
};

Possible Solution

No response

Additional Context

No response

@HypeMC
Copy link
Contributor

HypeMC commented Feb 18, 2024

@arderyp Hi, could you see if #53989 fixes your issue?

@arderyp
Copy link
Contributor Author

arderyp commented Feb 18, 2024

hey @HypeMC thank you so much for working on it! I will test your commits now and get back to you ASAP

@arderyp
Copy link
Contributor Author

arderyp commented Feb 18, 2024

thanks @HypeMC, I commented on the PR. That solved the bug!

@arderyp
Copy link
Contributor Author

arderyp commented Feb 18, 2024

@HypeMC do you know the procedure here for getting this merged? Should I @ certain people to review?

@HypeMC
Copy link
Contributor

HypeMC commented Feb 18, 2024

@arderyp No need, the best thing is to wait, in my experience it usually doesn't take to long. They release patch versions every month.

@arderyp
Copy link
Contributor Author

arderyp commented Feb 18, 2024

Amazing. I will keep an eye out, again, thank you so much! The way I was trying to fix/patch it was definitely not the approach you followed as I wasn't fully understanding the bug. Your solution is much more proper and comprehensive.

nicolas-grekas added a commit that referenced this issue Feb 20, 2024
…ded in `build()` (HypeMC)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle] Fix config builder with extensions extended in `build()`

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53987
| License       | MIT

The problem is caused by the fact that the Security bundle configuration can be extended in any `Bundle::build()` or the `Kernel::build()` methods.

Commits
-------

7053385 [FrameworkBundle] Fix config builder with extensions extended in `build()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants