knpuniversity / oauth2-client-bundle

Easily talk to an OAuth2 server for social functionality in Symfony
https://symfonycasts.com
MIT License
787 stars 145 forks source link

Security Guard has been deprecated and is excluded from Symfony 6.2 #394

Closed mgwebinc closed 1 year ago

mgwebinc commented 1 year ago

AbstractAuthenticator is now part of http security.

bocharsky-bw commented 1 year ago

Hey @mgwebinc !

What are you referencing with this issue? If you're talking about our docs - we show both ways: the legacy Guard way for BC and the new way here: https://github.com/knpuniversity/oauth2-client-bundle#authenticating-with-the-new-symfony-authenticator

Can we close this issue?

mrbinr commented 1 year ago

Hi, In the document in Authenticating with Guard part the example starts with

namespace App\Security;

use App\Entity\User; // your user entity
use Doctrine\ORM\EntityManagerInterface;
use KnpU\OAuth2ClientBundle\Security\Authenticator\SocialAuthenticator;
...
class MyFacebookAuthenticator extends SocialAuthenticator
{

but SocialAuthenticator extends AbstractGuardAuthenticator as you can see

use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;

abstract class SocialAuthenticator extends AbstractGuardAuthenticator
{

and AbstractGuardAuthenticator seems to be deprecated and I have this error :

Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#5973
  #message: """
    Attempted to load class "AbstractGuardAuthenticator" from namespace "Symfony\Component\Security\Guard".\n
    Did you forget a "use" statement for another namespace?
    """

I am using PHP 8.2.4 and Symfony 6.2

bocharsky-bw commented 1 year ago

Hey @mrbinr ,

Yes, Guard is deprecated and left in the docs only for legacy projects. Please, follow the new way with: https://github.com/knpuniversity/oauth2-client-bundle#authenticating-with-the-new-symfony-authenticator in case you're using a newer Symfony version