Просмотр исходного кода

Changed fixtures and fixed show-stoppers.

Ralfp 12 лет назад
Родитель
Сommit
84b1ee42c8

+ 1 - 1
misago/activation/views.py

@@ -4,7 +4,7 @@ from misago.banning.models import check_ban
 from misago.banning.decorators import block_banned
 from misago.banning.views import error_banned
 from misago.forms.layouts import FormLayout
-from misago.authn.means import sign_user_in
+from misago.authn.methods import sign_user_in
 from misago.authn.decorators import block_authenticated
 from misago.activation.forms import UserSendActivationMailForm
 from misago.bruteforce.decorators import block_jammed

+ 54 - 0
misago/authn/fixtures.py

@@ -0,0 +1,54 @@
+from misago.settings.fixtures import load_settings_fixture, update_settings_fixture
+from misago.utils import ugettext_lazy as _
+from misago.utils import get_msgid
+
+settings_fixtures = (
+    # Register and Sign-In Settings
+    ('signin', {
+        'name': _("Sign-In and Sessions Settings"),
+        'description': _("Those settings control behaviour of signed-in accounts."),
+        'settings': (
+            ('sessions_validate_ip', {
+                'value':        True,
+                'type':         "boolean",
+                'input':        "yesno",
+                'separator':    _("Sign-In Settings"),
+                'name':         _("Check IP on session authorization"),
+                'description':  _("Makes sessions more secure, but can cause problems with proxies and VPN's."),
+                'position':     0,
+            }),
+            ('remember_me_allow', {
+                'value':        True,
+                'type':         "boolean",
+                'input':        "yesno",
+                'name':         _('Enable "Remember Me" functionality'),
+                'description':  _("Turning this option on allows users to sign in on to your board using cookie-based tokens. This may result in account compromisation when user fails to sign out on shared computer."),
+                'position':     1,
+            }),
+            ('remember_me_lifetime', {
+                'value':        90,
+                'type':         "integer",
+                'input':        "text",
+                'name':         _('"Remember Me" token lifetime'),
+                'description':  _('Number of days since either last use or creation of "Remember Me" token to its expiration.'),
+                'position':     2,
+            }),
+            ('remember_me_extensible', {
+                'value':        1,
+                'type':         "boolean",
+                'input':        "yesno",
+                'name':         _('Allow "Remember Me" tokens refreshing'),
+                'description':  _('Set this setting to off if you want to force your users to periodically update their "Remember Me" tokens by signing in. If this option is on, Tokens are updated when they are used to open new session.'),
+                'position':     3,
+            }),
+        ),
+    }),
+)
+
+
+def load_fixtures():
+    load_settings_fixture(settings_fixtures)
+    
+    
+def update_fixtures():
+    update_settings_fixture(settings_fixtures)

+ 1 - 1
misago/authn/views.py

@@ -8,7 +8,7 @@ from misago.csrf.decorators import check_csrf
 from misago.banning.decorators import block_banned
 from misago.forms.layouts import FormLayout
 from misago.messages import Message
-from misago.authn.methods import auth
+import misago.authn.methods as auth
 from misago.authn.decorators import block_authenticated, block_guest
 from misago.authn.forms import SignInForm
 from misago.authn.methods import AuthException, auth_admin, auth_forum, sign_user_in

+ 49 - 0
misago/bruteforce/fixtures.py

@@ -0,0 +1,49 @@
+from misago.settings.fixtures import load_settings_fixture, update_settings_fixture
+from misago.utils import ugettext_lazy as _
+from misago.utils import get_msgid
+
+settings_fixtures = (
+    # Register and Sign-In Settings
+    ('brute-force', {
+        'name': _("Brute-force Countermeasures"),
+        'description': _("Those settings allow you to increase security of your members accounts."),
+        'settings': (
+            ('attempts_limit', {
+                'value':        3,
+                'default':      3,
+                'type':         "integer",
+                'input':        "text",
+                'separator':    _("Brute-force Countermeasures"),
+                'name':         _("IP invalid attempts limit"),
+                'description':  _('Enter maximal number of allowed attempts before IP address "jams". Defautly forum records only failed sign-in attempts.'),
+                'position':     0,
+            }),
+            ('registrations_jams', {
+                'value':        1,
+                'default':      1,
+                'type':         "boolean",
+                'input':        "yesno",
+                'name':         _("Protect register form"),
+                'description':  _("Set this setting to yes if you want failed register attempts to count into limit. Majority of failed register attempts are caused by CAPTCHA protection against spam-bots, however same protection may cause problems for users with disabilities or ones that have problems understanding Q&A challenge."),
+                'position':     1,
+            }),
+            ('jams_lifetime', {
+                'value':        15,
+                'default':      15,
+                'type':         "integer",
+                'input':        "text",
+                'name':         _("Automaticaly unlock jammed IPs"),
+                'description':  _('Enter number of minutes since IP address "jams" to automatically unlock it, or 0 to never unlock jammed IP adresses. Jams don\'t count as bans.'),
+                'position':     2,
+            }),
+        ),
+    }),
+)
+
+
+def load_fixtures():
+    load_settings_fixture(settings_fixtures)
+    
+    
+def update_fixtures():
+    update_settings_fixture(settings_fixtures)

+ 2 - 2
misago/bruteforce/models.py

@@ -20,7 +20,7 @@ class SignInAttemptsManager(models.Manager):
         
     def is_jammed(self, settings, ip):
         # Limit is off, dont jam IPs?
-        if settings['login_attempts_limit'] == 0:
+        if settings['attempts_limit'] == 0:
             return False
         # Check jam
         if settings['jams_lifetime'] > 0:
@@ -30,7 +30,7 @@ class SignInAttemptsManager(models.Manager):
                                                     )
         else:
             attempts = SignInAttempt.objects.filter(ip=ip)
-        return attempts.count() > settings['login_attempts_limit']
+        return attempts.count() > settings['attempts_limit']
     
     
 class SignInAttempt(models.Model):

+ 2 - 64
misago/register/fixtures.py

@@ -4,8 +4,8 @@ from misago.utils import get_msgid
 
 settings_fixtures = (
     # Register and Sign-In Settings
-    ('register-and-signin', {
-        'name': _("Register and Sign-In Settings"),
+    ('accounts', {
+        'name': _("Member Accounts Settings"),
         'description': _("Those settings allow you to increase security of your members accounts."),
         'settings': (
             ('account_activation', {
@@ -59,74 +59,12 @@ settings_fixtures = (
                 'description':  _("If you want to, Misago can include new user password in welcoming e-mail that is sent to new users after successful account creation."),
                 'position':     5,
             }),
-            ('sessions_validate_ip', {
-                'value':        True,
-                'type':         "boolean",
-                'input':        "yesno",
-                'name':         _("Check IP on session authorization"),
-                'description':  _("Makes sessions more secure, but can cause problems with proxies and VPN's."),
-                'position':     6,
-            }),
-            ('remember_me_allow', {
-                'value':        True,
-                'type':         "boolean",
-                'input':        "yesno",
-                'separator':    _("Sign-In Settings"),
-                'name':         _('Enable "Remember Me" functionality'),
-                'description':  _("Turning this option on allows users to sign in on to your board using cookie-based tokens. This may result in account compromisation when user fails to sign out on shared computer."),
-                'position':     7,
-            }),
-            ('remember_me_lifetime', {
-                'value':        90,
-                'type':         "integer",
-                'input':        "text",
-                'name':         _('"Remember Me" token lifetime'),
-                'description':  _('Number of days since either last use or creation of "Remember Me" token to its expiration.'),
-                'position':     8,
-            }),
-            ('remember_me_extensible', {
-                'value':        1,
-                'type':         "boolean",
-                'input':        "yesno",
-                'name':         _('Allow "Remember Me" tokens refreshing'),
-                'description':  _('Set this setting to off if you want to force your users to periodically update their "Remember Me" tokens by signing in. If this option is on, Tokens are updated when they are used to open new session.'),
-                'position':     9,
-            }),
-            ('login_attempts_limit', {
-                'value':        3,
-                'default':      3,
-                'type':         "integer",
-                'input':        "text",
-                'separator':    _("Brute-Force Countermeasures"),
-                'name':         _("Limit Sign In attempts"),
-                'description':  _('Enter maximal number of allowed Sign In attempts before IP address "jams".'),
-                'position':     10,
-            }),
-            ('registrations_jams', {
-                'value':        1,
-                'default':      1,
-                'type':         "boolean",
-                'input':        "yesno",
-                'name':         _("Count failed register attempts too"),
-                'description':  _("Set this setting to yes if you want failed register attempts to count into limit."),
-                'position':     11,
-            }),
-            ('jams_lifetime', {
-                'value':        15,
-                'default':      15,
-                'type':         "integer",
-                'input':        "text",
-                'name':         _("Automaticaly unlock jammed IPs"),
-                'description':  _('Enter number of minutes since IP address "jams" to automatically unlock it, or 0 to never unlock jammed IP adresses. Jams dont count as bans.'),
-                'position':     12,
-            }),
         ),
     }),
 )
 
 
 def load_fixtures():
-    load_monitor_fixture(monitor_fixtures)
     load_settings_fixture(settings_fixtures)