question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seems like `context.csrf` is being set without me doing anything

See original GitHub issue

I am debugging my project and have a breakpoint set at this line: https://github.com/koajs/csrf/blob/master/src/index.js#L56

Now when I evaluate (ctx.csrf), I get a value back. However I am not sending a CSRF token anywhere in my application…all I’ve done is set Koa to use the CSRF middleare…I haven’t embedded _csrf in a hidden form field anywhere, nor have I appended a csrf token to any of my requests. So my question is, how is ctx.csrf already set?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stephenmathiesoncommented, Oct 23, 2017

Yes, the token is set whether or not you send it. This library asserts that the token was provided by the user.

It’s clear that a “real” example is necessary here. I’ll see if I can throw something together in shortly.

0reactions
stephenmathiesoncommented, Oct 25, 2017

The token is valid for the duration of the user’s session in SPAs and for each request otherwise. Basically any time we can create a new token, we will.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django admin login suddenly demanding csrf token
This error was appearing for me when I had not set CSRF_COOKIE_DOMAIN in my settings_local but it was set in my main settings.py....
Read more >
What is CSRF (Cross-site request forgery)? Tutorial & Examples
Cross-site request forgery (also known as CSRF) is a web security vulnerability that allows an attacker to induce users to perform actions that...
Read more >
How to avoid getting "csrf failed"? · Issue #817 · oauth2-proxy ...
I can reproduce this 100% of the time, by clearing all data in Chrome, and then attempting to login. It will result in...
Read more >
19. Cross Site Request Forgery (CSRF) - Spring
The issue is that the HTTP request from the bank's website and the request from the evil website are exactly the same. This...
Read more >
Preventing CSRF Attacks with the SameSite Cookie Attribute
This article explains how the Samesite web cookie attribute works and how it can be used to prevent cross-site request forgery (CSRF) attacks....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found