User Authentication in Symfony2 with

Originally published at: is a handy user management tool and API. It provides a web interface to deal with user accounts (and the many features this involves) and an API to hook them into your own web application. The purpose of this service is to make it easier and safer to manage user authentication by not having to worry about that on your own server.

It has SDKs and various wrappers for many programming languages and frameworks and the price is affordable. Yes, it comes with a price but you can get started freely with quite a lot of things to play around with. I recommend checking out their features page to get more information. Also, it’s very easy to create an account and experiment with creating users, adding properties to their profiles, etc, so I recommend you check that out as well if you haven’t already.

In this article, we are going to look at how we can implement a Symfony2 authentication mechanism that leverages The code we write can also be found in this small library I created (currently in dev) that you can try out. To install it in your Symfony app, just follow the instructions on GitHub.


In order to communicate with the service, we will make use of their PHP library. Make sure you require this in your Symfony application’s composer.json file as instructed on their GitHub page.

The classes

To authenticate users with our Symfony app, we’ll create a few classes:

  • A form authenticator class used to perform the authentication with the API
  • A custom User class used to represent our users with information gathered from the API
  • A user provider class used to retrieve users and transform them into objects of our User class
  • A Token class used to represent the Symfony authentication token
  • A logout handler class that takes care of logging out from the service.
  • A simple exception class that we can throw if the users don’t have any permissions set (that we will convert to Symfony roles)

Once we create these classes, we will declare some of them as services and use them within the Symfony security system.

Continue reading this article on SitePoint

This also works with soap webservice ?
where they would have to change to work with a soap webservice ?
regards :grin:


I’m not sure. You can consult their website to see what can and cannot be done with their service. Personally, REST is all I care about :smile:

I have to do something similar but instead of using have to
use soap webservice that changes would have to do in this instance?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.