Symfony 2 - FOSUserBundle - how to integrate in API Symfony 2 - FOSUserBundle - how to integrate in API symfony symfony

Symfony 2 - FOSUserBundle - how to integrate in API


I have this problem too.I found the best solution is this

use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;class YourController extends Controller{//Other Methods..public function loginAction(Request $request){    try{        $token = $this->get('security.authentication.manager')->authenticate(new UsernamePasswordToken('username', 'password', 'firewall'));        $this->get('security.context')->setToken($token);    }    catch(BadCredentialsException $e){        return new Response("Bad credentials", 403);    }    return new Response("success");}}


I used the FOSRestBundle.

This bundle is very powerful and simple to implement.The documentation is pretty complete.

The github link of FOSRestBundle here

Hope that it helps


You need to check WSSE and how to integrate it to symfony. Also check this post. And there is a bundle that implementing WSSE authentication. WSSE one of the best solutions for your app.