diff options
| author | xrg <> | 2009-11-20 20:01:04 +0530 |
|---|---|---|
| committer | Harry (Open ERP) <hmo@tinyerp.com> | 2009-11-20 20:01:04 +0530 |
| commit | dad1ff955b636ccbad687f2f3f731ee8f512bd6f (patch) | |
| tree | e3405d96ef59f72094e5e300db24fb713e2b8838 /bin/service/security.py | |
| parent | b2a9a804ebf6c93ebe98751dd6b1008b8fe09306 (diff) | |
| parent | f566ea57a83bab87a8c7fa9743d190b4520c89e2 (diff) | |
[merge] merge from lp:~xrg/openobject-server/optimize-5.0 and removed some confilts
bzr revid: hmo@tinyerp.com-20091120143104-tb6136unkdw7yfy9
Diffstat (limited to 'bin/service/security.py')
| -rw-r--r-- | bin/service/security.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/service/security.py b/bin/service/security.py index 3ff9b90a317..23c67c9b7e1 100644 --- a/bin/service/security.py +++ b/bin/service/security.py @@ -24,6 +24,13 @@ import tools _uid_cache = {} +# When rejecting a password, we need to give as little info as possible +class ExceptionNoTb(Exception): + def __init__(self, msg ): + # self.message = msg # No need in Python 2.6 + self.traceback = ('','','') + self.args = (msg, '') + def login(db, login, password): cr = pooler.get_db(db).cursor() if password: @@ -41,7 +48,7 @@ def check_super(passwd): if passwd == tools.config['admin_passwd']: return True else: - raise Exception('AccessDenied') + raise ExceptionNoTb('AccessDenied') def check(db, uid, passwd): cached_pass = _uid_cache.get(db, {}).get(uid) @@ -55,7 +62,7 @@ def check(db, uid, passwd): res = cr.fetchone()[0] cr.close() if not bool(res): - raise Exception('AccessDenied') + raise ExceptionNoTb('AccessDenied') if res: if _uid_cache.has_key(db): ulist = _uid_cache[db] @@ -73,8 +80,9 @@ def access(db, uid, passwd, sec_level, ids): res = cr.fetchone() cr.close() if not res: - raise Exception('Bad username or password') + raise ExceptionNoTb('Bad username or password') return res[0] + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
