I'm currently developing a new set of Restfull APIs on Symfony2.1, and they are for the moment under no firewall in my security.yml
api:
pattern: ^/api
security: false
I have a RequestListener that "protect" them by checking if users give an Auth token or use Basic Auth. After correct login, we populate the security context with the user. (Maybe we could even make a firewall of that using a Factory?)
This works perfectly for external devs / organisations who want to use our API in their apps.
Now, I'd like us to rely on these same APIs inside our project (controllers, ajax calls..) and I was wondering now if we have to implement ourselves the API get-token or Basic Auth process to populate the security context of the API or if they could, in a way or another, retrieve magically the current security context of the main firewall. (it would save me the embarrassment of geting a token, saving it somewhere and passing it through my Backbonejs ajax calls all the way in my views).
Thanks for your thoughts on that! :)