First time here? Check out the FAQ!
1

CSRF token missing or incorrect

When I try to change the skin for Askbot, I get the following error:

Forbidden (403) 

CSRF verification failed. Request aborted.
Reason given for failure:
    CSRF token missing or incorrect.

This puts me in a catch 22 situation whereby I need to change the skin to fix the error, but without fixing the error I can't change the skin. Can anyone tell me how to get round this?

Edit: I'm using the default skin. I don't know which templates are used in the settings interface. I would prefer a solution that didn't involve editing the default skin templates as those changes would be harder to maintain.

Evgeny's avatar
13.2k
Evgeny
updated 2011-11-10 10:48:26 -0600
anonymous user
asked 2011-06-09 03:52:14 -0600
edit flag offensive 0 remove flag close merge delete

Comments

In the case you've set up your setting.py manually, please make sure yours is carefully "spliced" with the one in askbot/setup_templates/settings.py as there are important pieces for the askbot app.
Evgeny's avatar Evgeny (2011-06-10 12:29:32 -0600) edit
add a comment see more comments

4 Answers

0

No sure whether it's a bug. I added a {% csrf_token %} after <form> tag at line 26. Then this issue solved. google

Roland's avatar
1
Roland
answered 2011-11-29 22:42:15 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

This 'CSRF verification failed' is still present in the current default skin (Nov 21st 2011), master branch. It prevents the user to log into the admin console, to change the skin. Is there any other way to change the skin? The one this site uses (default in the packaged version of askbot) does work...

quesada's avatar
65
quesada
answered 2011-11-10 09:58:00 -0600
edit flag offensive 0 remove flag delete link

Comments

Hello, the CSRF verification failure is due to an error in the configuration, not a bug in the software. You just need to set the domain name correctly in the CSRF_COOKIE_DOMAIN setting.

Evgeny's avatar Evgeny (2011-11-10 10:47:43 -0600) edit
add a comment see more comments
1

I had this problem as well. I figured out a csrf token missed at file askbot/deps/livesettings/templates/livesettings/group_settings.html.

No sure whether it's a bug. I added a {% csrf_token %} after <form> tag at line 26. Then this issue solved.

zephyr's avatar
33
zephyr
answered 2011-07-10 23:11:31 -0600
edit flag offensive 0 remove flag delete link

Comments

cool, thanks. I've added this change to the repo code, will update on the pypi index this week as well.
Evgeny's avatar Evgeny (2011-07-11 01:17:37 -0600) edit
Thank your for this wonderful project. I've integrate it into our project and it works very well.
zephyr's avatar zephyr (2011-07-11 16:18:43 -0600) edit
add a comment see more comments
0

Do your templates have {% csrf_token %} inside each <form>? I'd add them right after the <form> opening tag.

The template tag inserts a hidden field with a token to prevent cross site scripting.

edit maybe you have something missing in the settings.py? Sorry, somehow I assumed you've customized the skin and lost the csrf_tokens.

You'd need:

  • 'django.core.context_processors.csrf' in TEMPLATE_CONTEXT_PROCESSORS
  • CSRF_COOKIE_NAME - some string
  • CSRF_COOKIE_DOMAIN - your domain name - like 'example.com'

If CSRF_COOKIE_DOMAIN does not match yours, you'll see that error.

Evgeny's avatar
13.2k
Evgeny
updated 2011-06-10 12:27:52 -0600, answered 2011-06-09 12:19:46 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments