django-log-formatter-asim 1.1.0a2__py3-none-any.whl → 1.1.0a3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,6 +51,12 @@ class AuthenticationUser(TypedDict):
51
51
  """
52
52
  username: Optional[str]
53
53
  """
54
+ Email address for the user if one exists.
55
+
56
+ Defaults to the logged in Django User.email if not provided.
57
+ """
58
+ email: Optional[str]
59
+ """
54
60
  A unique identifier for this authentication session if one exists.
55
61
 
56
62
  Defaults to the Django Sessions session key if not provided.
@@ -128,8 +134,8 @@ def log_authentication(
128
134
 
129
135
  if "hostname" in server:
130
136
  log["DvcHostname"] = server["hostname"]
131
- elif "SERVER_NAME" in request.META:
132
- log["DvcHostname"] = request.META["SERVER_NAME"]
137
+ elif "HTTP_HOST" in request.META:
138
+ log["DvcHostname"] = request.get_host()
133
139
 
134
140
  if "ip_address" in client:
135
141
  log["SrcIpAddr"] = client["ip_address"]
@@ -138,7 +144,7 @@ def log_authentication(
138
144
 
139
145
  if "requested_url" in client:
140
146
  log["TargetUrl"] = client["requested_url"]
141
- elif "SERVER_NAME" in request.META:
147
+ elif "HTTP_HOST" in request.META:
142
148
  log["TargetUrl"] = request.scheme + "://" + request.get_host() + request.get_full_path()
143
149
 
144
150
  if "role" in user:
@@ -150,9 +156,14 @@ def log_authentication(
150
156
  log["ActorSessionId"] = request.session.session_key
151
157
 
152
158
  if "username" in user:
153
- log["ActorUsername"] = user["username"]
154
- elif request.user.username:
155
- log["ActorUsername"] = request.user.username
159
+ log["TargetUsername"] = user["username"]
160
+ elif hasattr(request, "user") and request.user.username:
161
+ log["TargetUsername"] = request.user.username
162
+
163
+ if "email" in user:
164
+ log["ActorUsername"] = user["email"]
165
+ elif hasattr(request, "user") and hasattr(request.user, "email") and request.user.email:
166
+ log["ActorUsername"] = request.user.email
156
167
 
157
168
  if result_details:
158
169
  log["EventResultDetails"] = result_details
@@ -35,7 +35,7 @@ class Server(TypedDict):
35
35
  """
36
36
  A unique identifier for the server which serviced the Authentication event.
37
37
 
38
- Defaults to the WSGI SERVER_NAME field if not provided.
38
+ Defaults to the WSGI HTTP_HOST field if not provided.
39
39
  """
40
40
  hostname: Optional[str]
41
41
  """Internet Protocol Address of the server serving this request."""
@@ -169,8 +169,8 @@ def log_file_activity(
169
169
 
170
170
  if "hostname" in server:
171
171
  log["DvcHostname"] = server["hostname"]
172
- elif "SERVER_NAME" in request.META:
173
- log["DvcHostname"] = request.META["SERVER_NAME"]
172
+ elif "HTTP_HOST" in request.META:
173
+ log["DvcHostname"] = request.get_host()
174
174
 
175
175
  if "ip_address" in client:
176
176
  log["SrcIpAddr"] = client["ip_address"]
@@ -179,13 +179,13 @@ def log_file_activity(
179
179
 
180
180
  if "requested_url" in client:
181
181
  log["TargetUrl"] = client["requested_url"]
182
- elif "SERVER_NAME" in request.META:
182
+ elif "HTTP_HOST" in request.META:
183
183
  log["TargetUrl"] = request.scheme + "://" + request.get_host() + request.get_full_path()
184
184
 
185
185
  if "username" in user:
186
- log["ActorUsername"] = user["username"]
186
+ log["TargetUsername"] = user["username"]
187
187
  elif request.user.username:
188
- log["ActorUsername"] = request.user.username
188
+ log["TargetUsername"] = request.user.username
189
189
 
190
190
  if result_details:
191
191
  log["EventResultDetails"] = result_details
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-log-formatter-asim
3
- Version: 1.1.0a2
3
+ Version: 1.1.0a3
4
4
  Summary: Formats Django logs in ASIM format.
5
5
  License: MIT
6
6
  Author: Department for Business and Trade Platform Team
@@ -0,0 +1,9 @@
1
+ django_log_formatter_asim/__init__.py,sha256=LDQQch2GKY6LRj-KOME393FCiwjisQ49ATWBEqAP4ZA,7684
2
+ django_log_formatter_asim/events/__init__.py,sha256=th8AEFNM-J5lNlO-d8Lk465jXqplE3IoTwj4DlscwYo,92
3
+ django_log_formatter_asim/events/authentication.py,sha256=OxWztyvgaIXRZm-ake_OrxVXoH4NVMW1PaWZQi67UN8,6863
4
+ django_log_formatter_asim/events/common.py,sha256=YJ_t6nXShoMwgqgezUzi1f5qA-8J5DcBJWTqwbdZehs,1358
5
+ django_log_formatter_asim/events/file_activity.py,sha256=Re51ZOrcy1k62bORruPwCTdhuQqExbN_OtZ9UuCgDBE,6967
6
+ django_log_formatter_asim-1.1.0a3.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
7
+ django_log_formatter_asim-1.1.0a3.dist-info/METADATA,sha256=3ivJhQmrP7al1vvMKK-zQX2iBiLX56nek4sLCUR9E1A,5581
8
+ django_log_formatter_asim-1.1.0a3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
9
+ django_log_formatter_asim-1.1.0a3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- django_log_formatter_asim/__init__.py,sha256=LDQQch2GKY6LRj-KOME393FCiwjisQ49ATWBEqAP4ZA,7684
2
- django_log_formatter_asim/events/__init__.py,sha256=th8AEFNM-J5lNlO-d8Lk465jXqplE3IoTwj4DlscwYo,92
3
- django_log_formatter_asim/events/authentication.py,sha256=OMAT4P8ZRmeEWngHTLvscGOXtRE8t39izZpdKNot2R8,6479
4
- django_log_formatter_asim/events/common.py,sha256=G6h4ftfrAzXBNd3EkhFQsMv5BdGW0XtdeBKJ43Ja70s,1360
5
- django_log_formatter_asim/events/file_activity.py,sha256=RPlzJm8TjdT3szx1wClULG29Sz9RNA16NQmUJwhxjTc,6978
6
- django_log_formatter_asim-1.1.0a2.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
7
- django_log_formatter_asim-1.1.0a2.dist-info/METADATA,sha256=fFVGcfHJ9wOQq19lqnulIV5PgvHc99m1Mt8aNuUSMS8,5581
8
- django_log_formatter_asim-1.1.0a2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
9
- django_log_formatter_asim-1.1.0a2.dist-info/RECORD,,