Skip to content
Snippets Groups Projects
Commit 1ad881b54a08 authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Limit the login size in LoginAttempt

The login data comes from an unauthenticated user so it could be very large and
thus fill the database. But indeed we don't need to have the full login to get
the LoginAttempt benefit, just the 1024 starting char is enough.

issue5381
review17901002
(grafted from 4d069b887e72)
parent 54fb18c35de8
No related merge requests found
* Limit the login size in LoginAttempt
Version 3.0.14 - 2016-02-06
* Bug fixes (see mercurial logs for details)
* Don't read historized user when evaluating record rules as it could lead to
......
......@@ -7,6 +7,7 @@
import hashlib
import time
import datetime
from functools import wraps
from itertools import groupby, ifilter
from operator import attrgetter
from ast import literal_eval
......@@ -478,7 +479,7 @@
the res.user table when in a long running process.
"""
__name__ = 'res.user.login.attempt'
login = fields.Char('Login')
login = fields.Char('Login', size=512)
@classmethod
def __register__(cls, module_name):
......@@ -494,4 +495,10 @@
return (datetime.datetime.now()
- datetime.timedelta(seconds=int(CONFIG['session_timeout'])))
def _login_size(func):
@wraps(func)
def wrapper(cls, login, *args, **kwargs):
return func(cls, login[:cls.login.size], *args, **kwargs)
return wrapper
@classmethod
......@@ -497,4 +504,5 @@
@classmethod
@_login_size
def add(cls, login):
cls.delete(cls.search([
('create_date', '<', cls.delay()),
......@@ -502,9 +510,10 @@
cls.create([{'login': login}])
@classmethod
@_login_size
def remove(cls, login):
cursor = Transaction().cursor
table = cls.__table__()
cursor.execute(*table.delete(where=table.login == login))
@classmethod
......@@ -505,9 +514,10 @@
def remove(cls, login):
cursor = Transaction().cursor
table = cls.__table__()
cursor.execute(*table.delete(where=table.login == login))
@classmethod
@_login_size
def count(cls, login):
cursor = Transaction().cursor
table = cls.__table__()
......@@ -516,6 +526,8 @@
& (table.create_date >= cls.delay())))
return cursor.fetchone()[0]
del _login_size
class UserAction(ModelSQL):
'User - Action'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment