FOSTwitterBundle icon indicating copy to clipboard operation
FOSTwitterBundle copied to clipboard

multiple authentication providers

Open bitgandtter opened this issue 12 years ago • 0 comments

Hi i use TwitterBundle, FacebookBundle and UserBundle in my application and try to put together this 3 authentication mechanisms, but only get the entry point of the firewall the first i set in my security configuration, so i implement a fix or workaround to this problem. Here is the solution i found:

Before:

TwitterListener.php

/**

  • Twitter authentication listener. */ class TwitterListener extends AbstractAuthenticationListener { protected function attemptAuthentication(Request $request) { if (true === $this->options['use_twitter_anywhere']) { if (null === $identity = $request->cookies->get('twitter_anywhere_identity')) { throw new AuthenticationException(sprintf('Identity cookie "twitter_anywhere_identity" was not sent.')); } if (false === $pos = strpos($identity, ':')) { throw new AuthenticationException(sprintf('The submitted identity "%s" is invalid.', $identity)); }

        return $this->authenticationManager->authenticate(TwitterAnywhereToken::createUnauthenticated(substr($identity, 0, $pos), substr($identity, $pos + 1)));
    } else {
        return $this->authenticationManager->authenticate(new TwitterUserToken());
    }
    

    } } After:

/**

  • Twitter authentication listener. */ class TwitterListener extends AbstractAuthenticationListener { protected function attemptAuthentication(Request $request) { if($request->getSession()->get("oauth_token", null) && $request->get("oauth_token", null) && $request->getSession()->get("oauth_token", null) === $request->get("oauth_token", null)) { if (true === $this->options['use_twitter_anywhere']) { if (null === $identity = $request->cookies->get('twitter_anywhere_identity')) { throw new AuthenticationException(sprintf('Identity cookie "twitter_anywhere_identity" was not sent.')); } if (false === $pos = strpos($identity, ':')) { throw new AuthenticationException(sprintf('The submitted identity "%s" is invalid.', $identity)); }

          return $this->authenticationManager->authenticate(TwitterAnywhereToken::createUnauthenticated(substr($identity, 0, $pos), substr($identity, $pos + 1)));
      } else {
          return $this->authenticationManager->authenticate(new TwitterUserToken());
      }
    }
    return null;
    

    } }

If there is another way to doit please answer me, thanks.

I will be very glad if TwitterBundle developers fix this issue and get the code merge into the branch.

bitgandtter avatar Jun 27 '12 03:06 bitgandtter