[PATCH] auth: reduce code duplication by removing generate_api_key implemented in utils2
Andrew Shadura
andrew at shadura.me
Fri May 15 12:07:35 EDT 2015
# HG changeset patch
# User Andrew Shadura <andrew at shadura.me>
# Date 1431706047 -7200
# Fri May 15 18:07:27 2015 +0200
# Node ID 95bffe63997d40bfab5ae6b8d1a54859d6275471
# Parent 6e8effd028bf41a132aee02e52ffc0bf990dadf4
auth: reduce code duplication by removing generate_api_key implemented in utils2
diff --git a/kallithea/controllers/admin/users.py b/kallithea/controllers/admin/users.py
--- a/kallithea/controllers/admin/users.py
+++ b/kallithea/controllers/admin/users.py
@@ -40,7 +40,7 @@ from kallithea.lib.exceptions import Def
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.user import UserMod
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__)
diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py
--- a/kallithea/lib/auth.py
+++ b/kallithea/lib/auth.py
@@ -143,21 +143,6 @@ def get_crypt_password(password):
def check_password(password, hashed):
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):
More information about the kallithea-general
mailing list