6

I'm new with symfony2 and i am trying to connect with FOSUserBundle via a rest api. The web browser authentication is working fine and I can create users with FOSUserBundle. In fact I want to build a webservice with Symfony. How can I connect a user vie rest ? Is it a bundle to use rest with symfony2 easily?

Thanks.

1

2 Answers 2

1

I would suggest using "Wsse" as authorization method.

You can read about that at this post. There is even a bundle that provide wsse routines.

About make REST-ful your app, i would suggest using FosRestBundle

Sign up to request clarification or add additional context in comments.

Comments

0

For authenticating the user, first you create an action that will take the user name and password. Then find the user from database according to the username and password. For making pass as in database you have to make the password as FOSUserBundle is making it. Later u need to create UsernamePasswordToken. For that u can use the following code in action

$providerKey = $this->container->getParameter('fos_user.firewall_name');
$token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles());
$this->container->get('security.context')->setToken($token); 

I think it will help you.

1 Comment

this is wrong answer. REST API must have custom authentication provider in order not to use cookies to maintain the logged in user. this is a fine article on how to do that. symfony.com/doc/2.0/cookbook/security/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.