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

Add CSRF option in UseSessions to override the configuration #859

Closed
changke opened this issue Jan 9, 2021 · 2 comments
Closed

Add CSRF option in UseSessions to override the configuration #859

changke opened this issue Jan 9, 2021 · 2 comments

Comments

@changke
Copy link
Contributor

changke commented Jan 9, 2021

Hi, it seems to me in v2 there is no way to explicitly specify CSRF-checking (like in v1 with @CsrfTokenRequired on certain route). It is always tuned on upon @UseSessions with cookie and settings.session.csrf.enabled set to true. Right?

This would lead to something inconvenient: Normally on a log-in page I would not use CSRF because a user there mostly has no session yet. But after login, if user visits that page and try to login again, Foal will throw an error "CSRF token missing or incorrect.". This scenario could happen e.g I have multiple account and want to sign in without signing out another one first.

The login controller code I use is identical as in the docs.

Or am I using Foal incorrectly? Thanks!

@LoicPoullain LoicPoullain added this to Backlog in Issue tracking via automation Jan 11, 2021
@LoicPoullain
Copy link
Member

Hi, it seems to me in v2 there is no way to explicitly specify CSRF-checking (like in v1 with @CsrfTokenRequired on certain route). It is always tuned on upon @UseSessions with cookie and settings.session.csrf.enabled set to true. Right?

Correct.

This would lead to something inconvenient: Normally on a log-in page I would not use CSRF because a user there mostly has no session yet. But after login, if user visits that page and try to login again, Foal will throw an error "CSRF token missing or incorrect.". This scenario could happen e.g I have multiple account and want to sign in without signing out another one first.

Could you simply include the CSRF token when it exists? I would recommend this approach to prevent an attacker from forcing you to log into another account with your current session.

However, this is true that a csrf option is missing in UseSessions to override the configuration behavior (like the openapi option). I thought I added it but apparently not. Let's add it in the next release.

@LoicPoullain LoicPoullain changed the title Using CSRF in v2 Add CSRF option in UseSessions to override the configuration Jan 11, 2021
@LoicPoullain LoicPoullain mentioned this issue Jan 11, 2021
5 tasks
@LoicPoullain
Copy link
Member

Resolved in v2.1

Issue tracking automation moved this from Backlog to Done / Closed This Release Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Issue tracking
  
Done / Closed This Release
Development

No branches or pull requests

2 participants