Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

CSRF protection middleware for the app? #828

Closed
tmfelwu opened this issue Aug 20, 2015 · 11 comments
Closed

CSRF protection middleware for the app? #828

tmfelwu opened this issue Aug 20, 2015 · 11 comments

Comments

@tmfelwu
Copy link

tmfelwu commented Aug 20, 2015

are there any plans to implement CSRF protection as the app uses cookie based authentication?

@pgrodrigues
Copy link
Contributor

This should indeed be addressed. You can follow the guidelines here, which suggests to use csurf express middleware.

You dont need to do anything in the frontend as long as you keep things within the Angular way, because Angular will deal with it by itself, as mentioned in the docs:

Angular provides a mechanism to counter XSRF. When performing XHR requests, the $http service reads a token from a cookie (by default, XSRF-TOKEN) and sets it as an HTTP header (X-XSRF-TOKEN). Since only JavaScript that runs on your domain could read the cookie, your server can be assured that the XHR came from JavaScript running on your domain. The header will not be set for cross-domain requests.

@codydaig
Copy link
Member

@sparshy https://github.com/expressjs/csurf would be my recommendation to start. :-D Happy Hacking!

@lirantal
Copy link
Member

I would also look into PayPal's Lusca project which as a candidate

@pgrodrigues
Copy link
Contributor

Didn't know lusca, it seems like a mix between csurf and helmet.

@codydaig
Copy link
Member

@sparshy Did that answer your question?

@tmfelwu
Copy link
Author

tmfelwu commented Aug 22, 2015

Yes @codydaig, thanks I will try to implement CSRF tokens on my branch as soon as I get time. Yo guys do have a future plan to implement it in the main branch?

@lirantal
Copy link
Member

@sparshy indeed, security is also something we're investing efforts in (specifically I've been working on this front as well with my previous PRs about session security/cookies, etc).

Would be great to see a PR for that whenever you have time to work on it

@lirantal lirantal added this to the 0.4.x milestone Aug 22, 2015
@trainerbill
Copy link
Contributor

If we go with Lusca, I will volunteer to do it. I am biased here :)

@lirantal
Copy link
Member

@sparshy I assume no update on this topic?
@trainerbill be my guest - can you quickly research lusca vs csurf / helmet? and let's start working on this PR

@codydaig
Copy link
Member

@codydaig
Copy link
Member

A PR has been submitted #997

@lirantal lirantal self-assigned this Oct 17, 2015
@codydaig codydaig modified the milestones: 0.5.0, 0.4.x Nov 7, 2015
lirantal added a commit that referenced this issue Feb 20, 2016
[feat] Added Lusca middleware for CSRF [fixes #828]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants