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 #3

Open
oscarotero opened this issue Jan 18, 2017 · 3 comments
Open

CSRF #3

oscarotero opened this issue Jan 18, 2017 · 3 comments

Comments

@oscarotero
Copy link
Member

A middleware for CSRF (Cross Site Request Forgery) should be really usefull but brings some chalenges:

  • How to manage the session?
  • How make it easy to work with ajax?

References:

@oscarotero oscarotero mentioned this issue Jan 18, 2017
@schnittstabil
Copy link
Member

schnittstabil commented Jan 18, 2017

Sessions are not necessarily needed, e.g. my schnittstabil/psr7-csrf-middleware is based on the JWT idea – it just depends on the use-cases.

schnittstabil/psr7-csrf-middleware also provides multiple ways to deal with ajax, plain old <input/> and twig-templates – hence feel free to ask me.

@schnittstabil
Copy link
Member

Btw, I'm planning to port schnittstabil/psr7-csrf-middleware to PSR-15 – but this has very low priority atm.

@zakirullin
Copy link

zakirullin commented May 15, 2018

@schnittstabil's solution is good enough! And it looks like production-ready! Good job!
Though, I've invented one which fits my needs better. It is more suitable in case you have some kind of session storage already, and I think you do, because it's essential to have this one in your project, and roughly saying there is no need in CSRF-protectoin without Auth. So! In my opinion, you shouldn't care about session_id storing-transfer mechanism. You can leave it for other packages, this way we'll preserve simplicity as well as single responsibility principles. As for example, I use https://github.com/psr7-sessions/storageless alongside with mentioned solution.
Any comments would be appreciated (especially from @schnittstabil , as your project is more valuable)! And yes, it is PSR-15 compatible!
https://github.com/zakirullin/csrf-middleware

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

3 participants