From c440d4e27cd1acc5aa557ebda301cde6bc1155b8 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 19 Apr 2011 14:19:10 -0400 Subject: added csrf tokens to all post forms --- askbot/deps/django_authopenid/views.py | 6 +++++ askbot/doc/source/index.rst | 1 + askbot/doc/source/optional-modules.rst | 26 +++++++++++++++++++++ askbot/skins/default/templates/answer_edit.html | 2 +- .../default/templates/authopenid/changeemail.html | 2 +- .../default/templates/authopenid/complete.html | 6 ++--- .../skins/default/templates/authopenid/signin.html | 4 ++-- .../templates/authopenid/signup_with_password.html | 4 ++-- askbot/skins/default/templates/avatar/add.html | 2 +- askbot/skins/default/templates/avatar/change.html | 4 ++-- .../default/templates/avatar/confirm_delete.html | 2 +- .../skins/default/templates/blocks/ask_form.html | 2 +- askbot/skins/default/templates/close.html | 2 +- askbot/skins/default/templates/feedback.html | 2 +- askbot/skins/default/templates/import_data.html | 2 +- askbot/skins/default/templates/question.html | 2 +- askbot/skins/default/templates/question_edit.html | 2 +- askbot/skins/default/templates/question_retag.html | 2 +- askbot/skins/default/templates/reopen.html | 2 +- .../default/templates/subscribe_for_tags.html | 2 +- .../default/templates/user_profile/user_edit.html | 2 +- .../user_profile/user_email_subscriptions.html | 2 +- .../templates/user_profile/user_moderate.html | 6 ++--- askbot/upfiles/avatars/Evgeny/honda-civic-08.jpg | Bin 0 -> 49605 bytes .../avatars/Evgeny/resized/128/honda-civic-08.jpg | Bin 0 -> 3864 bytes .../avatars/Evgeny/resized/48/honda-civic-08.jpg | Bin 0 -> 1283 bytes .../avatars/Evgeny/resized/80/honda-civic-08.jpg | Bin 0 -> 2094 bytes askbot/views/avatar_views.py | 4 ++++ askbot/views/commands.py | 4 ++++ askbot/views/meta.py | 2 ++ askbot/views/readers.py | 2 ++ askbot/views/users.py | 6 ++++- askbot/views/writers.py | 7 +++++- 33 files changed, 83 insertions(+), 29 deletions(-) create mode 100644 askbot/doc/source/optional-modules.rst create mode 100755 askbot/upfiles/avatars/Evgeny/honda-civic-08.jpg create mode 100755 askbot/upfiles/avatars/Evgeny/resized/128/honda-civic-08.jpg create mode 100755 askbot/upfiles/avatars/Evgeny/resized/48/honda-civic-08.jpg create mode 100755 askbot/upfiles/avatars/Evgeny/resized/80/honda-civic-08.jpg diff --git a/askbot/deps/django_authopenid/views.py b/askbot/deps/django_authopenid/views.py index 411f18ef..bda0e66f 100644 --- a/askbot/deps/django_authopenid/views.py +++ b/askbot/deps/django_authopenid/views.py @@ -40,6 +40,7 @@ from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required from django.contrib.auth import authenticate from django.core.urlresolvers import reverse +from django.views.decorators import csrf from django.utils.encoding import smart_unicode from django.utils.html import escape from django.utils.translation import ugettext as _ @@ -258,6 +259,7 @@ def complete_oauth_signin(request): return HttpResponseRedirect(next_url) #@not_authenticated +@csrf.csrf_protect def signin( request, newquestion = False,#todo: not needed @@ -447,6 +449,7 @@ def signin( view_subtype = view_subtype ) +@csrf.csrf_protect def show_signin_view( request, login_form = None, @@ -690,6 +693,7 @@ def finalize_generic_signin( return HttpResponseRedirect(redirect_url) @not_authenticated +@csrf.csrf_protect def register(request, login_provider_name=None, user_identifier=None): """ this function is used via it's own url with request.method=POST @@ -833,6 +837,7 @@ def signin_failure(request, message): @not_authenticated @decorators.valid_password_login_provider_required +@csrf.csrf_protect def signup_with_password(request): """Create a password-protected account template: authopenid/signup_with_password.html @@ -1024,6 +1029,7 @@ def send_new_email_key(user,nomessage=False): set_email_validation_message(user) @login_required +@csrf.csrf_protect def send_email_key(request): """ url = /email/sendkey/ diff --git a/askbot/doc/source/index.rst b/askbot/doc/source/index.rst index 19d94c26..981af741 100644 --- a/askbot/doc/source/index.rst +++ b/askbot/doc/source/index.rst @@ -22,6 +22,7 @@ at the forum_ or by email at admin@askbot.org Import data (StackExchange) Appendix A: Maintenance procedures Appendix B: Sending email to askbot + Apperdix C: Optional modules Contributors Some background information: Askbot is written in Python on top of the Django platform. diff --git a/askbot/doc/source/optional-modules.rst b/askbot/doc/source/optional-modules.rst new file mode 100644 index 00000000..d7ca2f24 --- /dev/null +++ b/askbot/doc/source/optional-modules.rst @@ -0,0 +1,26 @@ +================ +Optional modules +================ + +Askbot supports a number of optional modules, enabling certain features, not available +in askbot by default. + +Uploaded avatars +================ + +To enable uploadable avatars (in addition to :ref:`gravatars `), +please install development version of +application ``django-avatar``, with the following command: + + pip install -e git+git://github.com/ericflo/django-avatar.git#egg=django-avatar + +Then add ``avatar`` to the list of ``INSTALLED_APPS`` in your ``settings.py`` file +and run (to install database table used by the avatar app): + + python manage.py syncdb + +.. note:: + + Version of the ``avatar`` application available at pypi may not + be up to date, so please take the development version from the + github repository diff --git a/askbot/skins/default/templates/answer_edit.html b/askbot/skins/default/templates/answer_edit.html index 0dc137ae..0d8b40da 100644 --- a/askbot/skins/default/templates/answer_edit.html +++ b/askbot/skins/default/templates/answer_edit.html @@ -11,7 +11,7 @@
-
+ {% csrf_token %}
{% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul() }}{% endif %}
diff --git a/askbot/skins/default/templates/authopenid/changeemail.html b/askbot/skins/default/templates/authopenid/changeemail.html index 52dc6a0c..1316a048 100644 --- a/askbot/skins/default/templates/authopenid/changeemail.html +++ b/askbot/skins/default/templates/authopenid/changeemail.html @@ -21,7 +21,7 @@

{{ msg }}

{% endif %}
- + {% csrf_token %} {% if next %} {% endif %} diff --git a/askbot/skins/default/templates/authopenid/complete.html b/askbot/skins/default/templates/authopenid/complete.html index ccaf753a..40ec4ccc 100644 --- a/askbot/skins/default/templates/authopenid/complete.html +++ b/askbot/skins/default/templates/authopenid/complete.html @@ -48,11 +48,11 @@ parameters: {% endif %}