jazzband / django-defender

A simple super fast django reusable app that blocks people from brute forcing login attempts
Apache License 2.0
1.04k stars 142 forks source link

defender looks for an url that doesn't exist #48

Closed n3storm closed 9 years ago

n3storm commented 9 years ago

First: I am not using django admin at all so I am not importing django defender urls.

Any idea why I'm getting following error?

[07/Aug/2015 13:46:43] ERROR [django.request:256] Internal Server Error: /panel/domain/list/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 164, in get_response
    response = response.render()
  File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 158, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 135, in rendered_content
    content = template.render(context, self._request)
  File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py", line 74, in render
    return self.template.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 209, in render
    return self._render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 201, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 903, in render
    bit = self.render_node(node, context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 79, in render_node
    return node.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 135, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 201, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 903, in render
    bit = self.render_node(node, context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 79, in render_node
    return node.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 903, in render
    bit = self.render_node(node, context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 79, in render_node
    return node.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 507, in render
    six.reraise(*exc_info)
  File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 493, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 579, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 496, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))
NoReverseMatch: Reverse for 'defender.decorators.decorated_login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
n3storm commented 9 years ago

My login page has this url:

{% url 'django.contrib.auth.views.login' %}

although code documentation states: "Used to decorate the django.contrib.admin.site.login method."

Am I getting closer?

kencochrane commented 9 years ago

Does the error go away when you add the defender URLs in?

Did you add defender to your application list in your settings?

n3storm commented 9 years ago

defender is in APPLICATIONs list for sure.

I just was trying adding defender URLs and that doesn't make any diference.

The error does not happen every time. The error goes as soon as django server is restarted (DEBUG True).

I am working with werkzeug now to see if anything changes (from django_extensions)

@kencochrane , two questions: Does defender has to be LAST or FIRST application listed? Does defender has to be LAST or FIRST middleware listed?

Because in either case and by the moment I cannot move to be last, but I don't think is a good idea to make it first?

n3storm commented 9 years ago

Hi there: After some developing defender finally crashed with Werkzeug server.

There is not a single trace about where is the origin of the call to 'defender.decorators.decorated_login'

This time defender was not first nor last in APPLICATIONS nor MIDDLEWARES and was listed not URLS.

I am starting combinations of this setup.

n3storm commented 9 years ago
Environment:

Request Method: GET
Request URL: http://devel.avis:9000/panel/login/

Django Version: 1.8.3
Python Version: 2.7.3
Installed Applications:
('django.contrib.sites',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.humanize',
 'django.contrib.staticfiles',
 'cacheops',
 'taggit',
 'ska.core.preferences_integration',
 'dynamic_preferences',
 'django_extensions',
 'storages',
 'reversion',
 'mptt',
 'colorfield',
 'custom_field',
 'bootstrap3_datetime',
 'django_select2',
 'django_rq',
 'compressor',
 'crispy_forms',
 'django_tables2',
 'genericm2m',
 'hooks',
 'django_nav',
 'ckeditor',
 'spurl',
 'captcha',
 'sorl.thumbnail',
 'parsley',
 'django_modalview',
 'categories',
 'categories.editor',
 'alert',
 'sequence_field',
 'ska.core.base',
 'django_bootstrap_breadcrumbs',
 'autocomplete_light',
 'ska.core.adminlte',
 'ska.core.fontawesome',
 'ska.core.steroids',
 'ska.core.dashboard',
 'ska.core.search',
 'watson',
 'ska.core.actstream_integration',
 'ska.core.accounts',
 'ska.apps.addressbook.people',
 'ska.core.calendar_integration',
 'fullcalendar',
 'defender',
 'ska.bundles.cms',
 'ska.apps.content.transmeta',
 'ska.apps.content.configurations',
 'ska.apps.content.treenav',
 'ska.apps.content.panel',
 'ska.apps.content.base',
 'ska.apps.content.taxonomy',
 'ska.apps.content.comments',
 'ska.apps.content.events',
 'ska.apps.content.resources',
 'ska.apps.content.pages',
 'ska.apps.content.posts',
 'ska.apps.content.products',
 'ska.apps.content.contactmessages',
 'ska.apps.content.mysite',
 'dominicasvistabella_com',
 'actstream')
Installed Middleware:
('django.middleware.gzip.GZipMiddleware',
 'htmlmin.middleware.HtmlMinifyMiddleware',
 'htmlmin.middleware.MarkRequestMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'ska.core.base.middleware.WorkspacesMiddleware',
 'defender.middleware.FailedLoginMiddleware',
 'ska.apps.content.mysite.middleware.MenttoHttp404Middleware',
 'ska.apps.content.mysite.middleware.MenttoSubsiteMiddleware')

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  164.                 response = response.render()
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in render
  158.             self.content = self.rendered_content
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in rendered_content
  135.         content = template.render(context, self._request)
File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in render
  74.         return self.template.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  209.                     return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
  201.         return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  903.                 bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_node
  917.         return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
  135.         return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
  201.         return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  903.                 bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_node
  917.         return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
  65.                 result = block.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  903.                 bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_node
  917.         return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
  507.                         six.reraise(*exc_info)
File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
  493.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in reverse
  579.     return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _reverse_with_prefix
  496.                              (lookup_view_s, args, kwargs, len(patterns), patterns))

Exception Type: NoReverseMatch at /panel/login/
Exception Value: Reverse for 'defender.decorators.decorated_login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
n3storm commented 9 years ago

I am having no problems with Gunicorn

mpars0ns commented 9 years ago

You might want to try taking a look at the following stack overflow

http://stackoverflow.com/a/8631551

I had a similar problem and that fixed me right up

n3storm commented 9 years ago

Trying this @mpars0ns right now. Love your avatar.

kencochrane commented 9 years ago

@n3storm are you all set now, or are you still having problems?

n3storm commented 9 years ago

Everything is okay thanks to @mpars0ns Ticket may be closed, not sure if this shoud be mentioned at docs.

Thanks everyone

kencochrane commented 9 years ago

@n3storm ok I'll close, if others have the same problem in the future we will make sure to add something to the docs.