*: make user logging more consistent

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-06-05 18:50:44 +02:00
parent 438aac8879
commit ca40d31dac
4 changed files with 8 additions and 8 deletions

View File

@ -88,7 +88,7 @@ class PolicyProcess(PROCESS_CLASS):
LOGGER.debug(
"P_ENG(proc): Running policy",
policy=self.binding.policy,
user=self.request.user,
user=self.request.user.username,
# this is used for filtering in access checking where logs are sent to the admin
process="PolicyProcess",
)
@ -124,7 +124,7 @@ class PolicyProcess(PROCESS_CLASS):
# this is used for filtering in access checking where logs are sent to the admin
process="PolicyProcess",
passing=policy_result.passing,
user=self.request.user,
user=self.request.user.username,
)
return policy_result

View File

@ -162,10 +162,10 @@ class IdentificationStageView(ChallengeStageView):
if not query:
self.logger.debug("Empty user query", query=query)
return None
users = User.objects.filter(query, is_active=True)
if users.exists():
self.logger.debug("Found user", user=users.first(), query=query)
return users.first()
user = User.objects.filter(query, is_active=True).first()
if user:
self.logger.debug("Found user", user=user.username, query=query)
return user
return None
def get_challenge(self) -> Challenge:

View File

@ -56,7 +56,7 @@ def authenticate(
continue
# Annotate the user object with the path of the backend.
user.backend = backend_path
LOGGER.debug("Successful authentication", user=user, backend=backend_path)
LOGGER.debug("Successful authentication", user=user.username, backend=backend_path)
return user
# The credentials supplied are invalid to all backends, fire signal

View File

@ -47,7 +47,7 @@ class UserLoginStageView(StageView):
self.logger.debug(
"Logged in",
backend=backend,
user=user,
user=user.username,
flow_slug=self.executor.flow.slug,
session_duration=self.executor.current_stage.session_duration,
)