Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSRF token missing for enctype="multipart/form-data" #70

Closed
erbridge opened this issue Oct 29, 2015 · 4 comments
Closed

CSRF token missing for enctype="multipart/form-data" #70

erbridge opened this issue Oct 29, 2015 · 4 comments

Comments

@erbridge
Copy link

I'm using lusca without krakenjs and am trying to get CSRF working with an image upload. I am parsing the form later in my route logic using multer.

How can I get CSRF to work with this?

@jasisk
Copy link
Member

jasisk commented Oct 29, 2015

multer will have to be earlier in the continuation than lusca as lusca needs to pluck the token off of the body (which isn't parsed until the multer middleware).

@erbridge
Copy link
Author

That's impractical for my use case. Alternatively, is there a built in way to exclude routes from requiring CSRF?

@jasisk
Copy link
Member

jasisk commented Oct 29, 2015

Sure thing. Check out the section on Route paths in the expressjs guide on routing. Short version is you can write a regular expression with a negative lookahead assertion. I wrote a small demo project documenting some middleware registration patterns which includes a blacklist pattern leveraging this.

In your case, since you're using vanilla express, I'd recommend writing a true regular expression instead of the string-based pattern I used in the above example project.

Closing but feel free to continue the conversation.

@jasisk jasisk closed this as completed Oct 29, 2015
@erbridge
Copy link
Author

Ah. Didn't know you could do that. Still not ideal, but it'll suffice. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants