The web part
As I understand with statement "i have made my client side code completely independent of my server side code", you mean that, your backend is on different host/port than angularJS app.
This makes troubles, beacuse of CORS:
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
How CSRF work:
- backend app: send cookie to browser with CSRF token
- browser: save token from backend app
- browser: send token with next POST/PUT/DELETE request
Your app fails in step 2, beacuse browser will save cookie only when protocol, host and port match those from frontend app.
If you want to implement custom CSRF tokens, you have to make $http
interceptor service which will deal with adding CSRF to requests and update current CSRF after request.
Doc: https://docs.angularjs.org/api/ng/service/$http (section interceptors)
To test if I am right, you can run browser with disabled web security. CSRF tokens will then be saved.
For chrome / chromium:
- Go to terminal
cd
to chrome folder
- Run
chrome --disable-web-security
The mobile app
Everything depends on your HTTP client in the app.
CSRF are actually cookies and they have to be sended in every request different than GET and updated after these requests. Please make sure, that your library is saving CSRF cookies and your web app sends CSRF cookies (not headers).