0

This is a continuation of my last question.

Hi,

I'm implementing, in a Symfony2 application, a custom authentication provider in order to authenticate against the Wordnik REST API.

On application load, no matter what request path, this is the exception I get:

( ! ) Fatal error: Cannot access parent:: when current class scope has no parent in /[..]/WordRot/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php on line 43

You can see the full stacktrace here.

Second to last line in the trace reveals that it is loading the DaoAuthenticationProvider:

18 0.0217 1922792 Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider->__construct( ) ../appDevDebugProjectContainer.php:3071

But none of my configuration refers to that provider, or anything that extends it. My custom provider directly implements the AuthenticationProviderInterface.

So I assume that my configuration is wrong, and somewhere I need to be explicitly setting the WordnikProvider, but I'm not sure where! Research has not provided any clues to this issue.

Any help would be much appreciated!

Files

Community
  • 1
  • 1
Daniel B.
  • 1,650
  • 1
  • 19
  • 40

2 Answers2

1

the line return $this->authenticationManager->authenticate(new WordnikUserToken($username, $password, $this->providerKey)); in the WordnikListener goes to Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager (classes.php) authenticate. $this->providers are DaoAuthentificationProvider, WordnikProvider and AnonymousAuthentificationProvider. From the DaoAuthentificationProvider it only uses the method supports($token): return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey();

which returns false so next in line is WordnikProvider.

Oh..misread: the error is in the constructor: parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); seems to fail. Running PHP 5.4.10 or so I DON'T have an error!!

Either rm -rf vendor and run composer install again or try using a different PHP version!!

hacfi
  • 756
  • 3
  • 7
  • Removing the vendors and re-installing them bypassed this error and revealed two very bizarre "class not found" errors in `bootstrap.php.cache` (depending on whether I ran `update` or `install`). As recommended, I upgraded my composer.phar, re-installed all vendors (on a fresh clone of the repo) and there were no more problems loading the WordnikProvider! Thanks for your help. – Daniel B. Feb 22 '13 at 18:11
0

A had to create something like this a week ago. At the and, I created a custom user provider, where I simply call the api and with the response i create the user or not.

I would advise to read this:

http://symfony.com/doc/2.0/cookbook/security/custom_provider.html

Community
  • 1
  • 1
ghostika
  • 1,473
  • 1
  • 12
  • 23
  • Thanks for your reply András. I've read about creating a custom UserProvider, but what I'm trying to implement right now is a custom AuthenticationProvider. Ideally I'd separate the logic, and handle authentication for the API within the AuthenticationProvider. – Daniel B. Feb 21 '13 at 22:40