Changeset - 6056c0e8244f
[Not reviewed]
default
0 4 0
Mads Kiilerich - 6 years ago 2020-03-22 23:05:36
mads@kiilerich.com
Grafted from: 74b0fae3756f
auth: don't use json for debug logging

The json formatting is just a source of error - it will for example crash if
there should be bytes anywhere.
4 files changed with 8 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/auth_settings.py
Show inline comments
 
@@ -37,7 +37,6 @@ from kallithea.lib import auth_modules
 
from kallithea.lib import helpers as h
 
from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
 
from kallithea.lib.base import BaseController, render
 
from kallithea.lib.compat import formatted_json
 
from kallithea.model.db import Setting
 
from kallithea.model.forms import AuthSettingsForm
 
from kallithea.model.meta import Session
 
@@ -87,7 +86,7 @@ class AuthSettingsController(BaseControl
 
        # we want to show , separated list of enabled plugins
 
        c.defaults['auth_plugins'] = ','.join(c.enabled_plugin_names)
 

	
 
        log.debug(formatted_json(defaults))
 
        log.debug('defaults: %s', defaults)
 
        return formencode.htmlfill.render(
 
            render('admin/auth/auth_settings.html'),
 
            defaults=c.defaults,
 
@@ -103,7 +102,7 @@ class AuthSettingsController(BaseControl
 
    def auth_settings(self):
 
        """POST create and store auth settings"""
 
        self.__load_defaults()
 
        log.debug("POST Result: %s", formatted_json(dict(request.POST)))
 
        log.debug("POST Result: %s", dict(request.POST))
 

	
 
        # First, parse only the plugin list (not the plugin settings).
 
        _auth_plugins_validator = AuthSettingsForm([]).fields['auth_plugins']
kallithea/lib/auth_modules/__init__.py
Show inline comments
 
@@ -20,7 +20,7 @@ import logging
 
import traceback
 

	
 
from kallithea.lib.auth import AuthUser, PasswordGenerator
 
from kallithea.lib.compat import formatted_json, hybrid_property
 
from kallithea.lib.compat import hybrid_property
 
from kallithea.lib.utils2 import str2bool
 
from kallithea.model.db import Setting, User
 
from kallithea.model.meta import Session
 
@@ -348,7 +348,7 @@ def authenticate(username, password, env
 
            conf_key = "auth_%s_%s" % (plugin_name, v["name"])
 
            setting = Setting.get_by_name(conf_key)
 
            plugin_settings[v["name"]] = setting.app_settings_value if setting else None
 
        log.debug('Settings for auth plugin %s:\n%s', plugin_name, formatted_json(plugin_settings))
 
        log.debug('Settings for auth plugin %s: %s', plugin_name, plugin_settings)
 

	
 
        if not str2bool(plugin_settings["enabled"]):
 
            log.info("Authentication plugin %s is disabled, skipping for %s",
kallithea/lib/auth_modules/auth_internal.py
Show inline comments
 
@@ -29,7 +29,7 @@ Original author and date, and relevant c
 
import logging
 

	
 
from kallithea.lib import auth_modules
 
from kallithea.lib.compat import formatted_json, hybrid_property
 
from kallithea.lib.compat import hybrid_property
 

	
 

	
 
log = logging.getLogger(__name__)
 
@@ -76,7 +76,7 @@ class KallitheaAuthPlugin(auth_modules.K
 
            "admin": userobj.admin,
 
            "extern_name": userobj.user_id,
 
        }
 
        log.debug(formatted_json(user_data))
 
        log.debug('user data: %s', user_data)
 

	
 
        from kallithea.lib import auth
 
        password_match = auth.check_password(password, userobj.password)
kallithea/lib/auth_modules/auth_pam.py
Show inline comments
 
@@ -32,7 +32,7 @@ import threading
 
import time
 

	
 
from kallithea.lib import auth_modules
 
from kallithea.lib.compat import formatted_json, hybrid_property
 
from kallithea.lib.compat import hybrid_property
 

	
 

	
 
try:
 
@@ -142,7 +142,7 @@ class KallitheaAuthPlugin(auth_modules.K
 
            log.warning("Cannot extract additional info for PAM user %s", username)
 
            pass
 

	
 
        log.debug("pamuser: \n%s", formatted_json(user_data))
 
        log.debug("pamuser: %s", user_data)
 
        log.info('user %s authenticated correctly', user_data['username'])
 
        return user_data
 

	
0 comments (0 inline, 0 general)