changeset 5215:7eb5bbbfb8dd stable

auth: reduce code duplication by removing generate_api_key implemented in utils2
author Andrew Shadura <andrew@shadura.me>
date Fri, 15 May 2015 18:07:27 +0200
parents a73f98871e2b
children 3e81e6534cad
files kallithea/controllers/admin/users.py kallithea/lib/auth.py
diffstat 2 files changed, 2 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/users.py	Tue Jun 09 22:12:21 2015 +0200
+++ b/kallithea/controllers/admin/users.py	Fri May 15 18:07:27 2015 +0200
@@ -40,7 +40,7 @@
     UserOwnsReposException, UserCreationError
 from kallithea.lib import helpers as h
 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator, \
-    AuthUser, generate_api_key
+    AuthUser
 import kallithea.lib.auth_modules.auth_internal
 from kallithea.lib import auth_modules
 from kallithea.lib.base import BaseController, render
@@ -52,7 +52,7 @@
 from kallithea.model.meta import Session
 from kallithea.lib.utils import action_logger
 from kallithea.lib.compat import json
-from kallithea.lib.utils2 import datetime_to_time, safe_int
+from kallithea.lib.utils2 import datetime_to_time, safe_int, generate_api_key
 
 log = logging.getLogger(__name__)
 
--- a/kallithea/lib/auth.py	Tue Jun 09 22:12:21 2015 +0200
+++ b/kallithea/lib/auth.py	Fri May 15 18:07:27 2015 +0200
@@ -144,20 +144,6 @@
     return KallitheaCrypto.hash_check(password, hashed)
 
 
-def generate_api_key(str_, salt=None):
-    """
-    Generates API KEY from given string
-
-    :param str_:
-    :param salt:
-    """
-
-    if salt is None:
-        salt = _RandomNameSequence().next()
-
-    return hashlib.sha1(str_ + salt).hexdigest()
-
-
 class CookieStoreWrapper(object):
 
     def __init__(self, cookie_store):