diff --git a/perun/proxygui/api/heuristic_api.py b/perun/proxygui/api/heuristic_api.py index 4da2d7a1e6316a168302ab05c0718ab603c94166..831c38bc584c0f41d477401e0a1e7d7d1ed3baff 100644 --- a/perun/proxygui/api/heuristic_api.py +++ b/perun/proxygui/api/heuristic_api.py @@ -81,6 +81,8 @@ class AuthEventLoggingQueries: # Basic checker if MFA was performed based on upstream_acrs value def upstream_acr_status(self, acr): + if not acr: + return None mfa_status = next((mfa for mfa in self.MFA_CONTEXTS if mfa in acr), None) return mfa_status is not None @@ -122,11 +124,18 @@ class AuthEventLoggingQueries: .join( requested_table, requested_table.c.id == auth_table.c.requested_acrs_id, + isouter=True, + ) + .join( + upstream_table, + upstream_table.c.id == auth_table.c.upstream_acrs_id, + isouter=True, ) .join( - upstream_table, upstream_table.c.id == auth_table.c.upstream_acrs_id + services_table, + services_table.c.id == auth_table.c.sp_id, + isouter=True, ) - .join(services_table, services_table.c.id == auth_table.c.sp_id) .where(auth_table.c.user_id == user_id) .distinct(auth_table.c.ip_address) ).alias("inner_query") @@ -146,7 +155,6 @@ class AuthEventLoggingQueries: ) .select_from(inner_query) .order_by(inner_query.c.day.desc()) - .limit(self.few_time_logs) ) response = cnxn.execute(outer_query).fetchall() @@ -175,9 +183,12 @@ class AuthEventLoggingQueries: .join( agents_raw_table, agents_raw_table.c.id == auth_table.c.user_agent_id, + isouter=True, ) .join( - upstream_table, upstream_table.c.id == auth_table.c.upstream_acrs_id + upstream_table, + upstream_table.c.id == auth_table.c.upstream_acrs_id, + isouter=True, ) .where(auth_table.c.user_id == user_id) .order_by(auth_table.c.day.desc())