orgtechservice / roskombox

Веб-приложение для проведения ручных и автоматических выгрузок реестра РКН и проверок доступности сайтов из реестра. Больше не развивается, смотрите соседний репозиторий «roskomtools».
11 stars 2 forks source link

Любой post-запрос генерит ошибку csrf #13

Closed dserov closed 8 years ago

dserov commented 8 years ago

Добрый день! Установил Ваш продукт по мануалу, ошибок не возникло. Залогинился. При попытке сменить пароль, закачать подписанный запрос или сохранении параметров выдается ошибка: Ошибка доступа (403) Ошибка проверки CSRF. Запрос отклонён.

WST commented 8 years ago

Это, скорее всего, связано с настройкой nginx, пока нет времени проверить, т.к занимаемся в фирме другими делами, будет возможность — глянем.

Сообщите пока версии используемого программного обеспечения, включая всё, что установлено в виртуаленве (список можно получить командой pip list или pip freeze), а также uWSGI и nginx. Попробуем воспроизвести.

dserov commented 8 years ago

Запрошенная информация. (roskombox) admin@xbtt~$: pip list

Django (1.10)
django-bootstrap-pagination (1.6.2)
django-crispy-forms (1.6.0)
django-jsonview (1.0.0)
django-sendmail-backend (0.1.2)
lxml (3.6.4)
mysqlclient (1.3.7)
pip (1.5.6)
requests (2.11.1)
rrdtool (0.1.5)
setuptools (5.5.1)
suds-py3 (1.3.2.0)
uwsgidecorators (1.1.0)

xbtt:/etc/nginx/sites-available# dpkg --list | grep uwsgi

ii  uwsgi                                2.0.7-1                           amd64        fast, self-healing application container server
ii  uwsgi-core                           2.0.7-1                           amd64        fast, self-healing application container server (core)
ii  uwsgi-emperor                        2.0.7-1                           amd64        fast, self-healing application container server (emperor scripts)
ii  uwsgi-plugin-python3                 2.0.7-1                           amd64        WSGI plugin for uWSGI (Python 3)

xbtt:/etc/nginx/sites-available# dpkg --list | grep nginx

ii  nginx-common                         1.6.2-5+deb8u1                    all          small, powerful, scalable web/proxy server - common files
ii  nginx-full                           1.6.2-5+deb8u1                    amd64        nginx web/proxy server (standard version)

xbtt:/etc/nginx/sites-available# dpkg --list | grep python

ii  dh-python                            1.20141111-2                      all          Debian helper tools for packaging Python libraries and applications
ii  libpython-stdlib:amd64               2.7.9-1                           amd64        interactive high-level object-oriented language (default python version)
ii  libpython2.7:amd64                   2.7.9-2                           amd64        Shared Python runtime library (version 2.7)
ii  libpython2.7-minimal:amd64           2.7.9-2                           amd64        Minimal subset of the Python language (version 2.7)
ii  libpython2.7-stdlib:amd64            2.7.9-2                           amd64        Interactive high-level object-oriented language (standard library, version 2.7)
ii  libpython3-dev:amd64                 3.4.2-2                           amd64        header files and a static library for Python (default)
ii  libpython3-stdlib:amd64              3.4.2-2                           amd64        interactive high-level object-oriented language (default python3 version)
ii  libpython3.4:amd64                   3.4.2-1                           amd64        Shared Python runtime library (version 3.4)
ii  libpython3.4-dev:amd64               3.4.2-1                           amd64        Header files and a static library for Python (v3.4)
ii  libpython3.4-minimal:amd64           3.4.2-1                           amd64        Minimal subset of the Python language (version 3.4)
ii  libpython3.4-stdlib:amd64            3.4.2-1                           amd64        Interactive high-level object-oriented language (standard library, version 3.4)
ii  python                               2.7.9-1                           amd64        interactive high-level object-oriented language (default version)
rc  python-central                       0.6.17                            all          register and build utility for Python packages
ii  python-chardet-whl                   2.3.0-1                           all          universal character encoding detector
ii  python-colorama-whl                  0.3.2-1                           all          Cross-platform colored terminal text in Python - Wheels
ii  python-distlib-whl                   0.1.9-1                           all          low-level components of python distutils2/packaging
rc  python-gobject-2                     2.28.6-12+b1                      amd64        deprecated static Python bindings for the GObject library
ii  python-html5lib-whl                  0.999-3                           all          HTML parser/tokenizer based on the WHATWG HTML5 specification
ii  python-minimal                       2.7.9-1                           amd64        minimal subset of the Python language (default version)
ii  python-pip-whl                       1.5.6-5                           all          alternative Python package installer
ii  python-requests-whl                  2.4.3-6                           all          elegant and simple HTTP library for Python, built for human beings
ii  python-setuptools-whl                5.5.1-1                           all          Python Distutils Enhancements (wheel package)
ii  python-six-whl                       1.8.0-1                           all          Python 2 and 3 compatibility library (universal wheel)
rc  python-support                       1.0.15                            all          automated rebuilding support for Python modules
ii  python-urllib3-whl                   1.9.1-3                           all          HTTP library with thread-safe connection pooling
ii  python2.7                            2.7.9-2                           amd64        Interactive high-level object-oriented language (version 2.7)
ii  python2.7-minimal                    2.7.9-2                           amd64        Minimal subset of the Python language (version 2.7)
ii  python3                              3.4.2-2                           amd64        interactive high-level object-oriented language (default python3 version)
ii  python3-dev                          3.4.2-2                           amd64        header files and a static library for Python (default)
ii  python3-minimal                      3.4.2-2                           amd64        minimal subset of the Python language (default python3 version)
ii  python3-pkg-resources                5.5.1-1                           all          Package Discovery and Resource Access using pkg_resources
ii  python3-venv                         3.4.2-2                           amd64        pyvenv-3 binary for python3 (default python3 version)
ii  python3.4                            3.4.2-1                           amd64        Interactive high-level object-oriented language (version 3.4)
ii  python3.4-dev                        3.4.2-1                           amd64        Header files and a static library for Python (v3.4)
ii  python3.4-minimal                    3.4.2-1                           amd64        Minimal subset of the Python language (version 3.4)
ii  python3.4-venv                       3.4.2-1                           amd64        Interactive high-level object-oriented language (pyvenv binary, version 3.4)
ii  uwsgi-plugin-python3                 2.0.7-1                           amd64        WSGI plugin for uWSGI (Python 3)
xbtt:/etc/nginx/sites-available#

nginx.conf содержит только то, что должен по мануалу, копи-паст.

dserov commented 8 years ago

Подозреваю, что условие "In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL." не выполняется. Браузер куки принимает, видно, что в запросе есть кука csrftoken. А вот в POST-форме нет поля csrftoken.

dserov commented 8 years ago

Заработало после даунгрейда Django. Спасибо за Ваш труд!