I'm building a REST API on symfony2 and I'm not sure what would be the best way to manage different security levels.
- Unauthenticated clients (apps or websites that have no permission to reach the API data) can't get (get, put, post, etc) data from the API
- Authenticated clients will be able to request some data from the API but not user related data.
- On the other hand, end users need to be logged in somehow to access some private resources from the API.
For example, api/v1/philosophies
would list all the phylosophies to an authenticated client. Unregistered end users could see the list: 'idealism, realism, existencialism, ...'.
But end users would need to be authorized (registered and logged) to access their favorite phylosophies through api/v1/user/{userID}/favorites
.
I've been reading and testing stuff with FOSUserBundle, FOSRestBundle and FOSOAuthServerBundle but all the information i find has the users always logged in order to get the token and the whole api is protected both by client and by users.
Any idea?
Some light?
please?