I'm building an application using backbone.js and web api. JS client will send ajax requests to access api. Building an API is pretty easy but i want to implement authentication and authorization for API.
I'm planning to return a token after a successful authentication and use this token for further requests. This token will be passed in HTTP Authorization headers. My requirements are as below 1) Verify token on each request and get user id. 2) Use fetched user id for further actions.
First bit can be handled using Custom action filter where the permanent token can be verified against the database. But i'm not able to find any sample or example for doing a second bit. I want to get a userid from a passed token and carry it further for later processing. Is there any way of doing it?
Waiting for suggestions or ideas. Any code sample will really help. Thanks in advance.