File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 179179 "level" : "INFO" ,
180180 "handlers" : ["console" , "slack_admins" ],
181181 },
182+ "downloads" : {
183+ "level" : "INFO" ,
184+ "handlers" : ["console" ],
185+ "propagate" : False ,
186+ },
182187 },
183188}
184189
Original file line number Diff line number Diff line change 3131from app .authentication import TokenAuthentication as SageTokenAuthentication
3232import time
3333from unittest .mock import patch
34+ import logging
35+
36+
37+ logger = logging .getLogger (__name__ )
3438
3539
3640@dataclass
@@ -299,6 +303,19 @@ def get(
299303 node_id ,
300304 timestamp_and_filename ,
301305 )
306+
307+ # Log the access attempt
308+ username = (
309+ request .user .username if request .user .is_authenticated else "anonymous"
310+ )
311+
302312 if self .file_is_public or has_object_permission (request .user , self .node ):
313+ logger .info (
314+ f"{ datetime .now (timezone .utc ).isoformat ()} file download allowed: username={ username } path={ request .path } is_public={ self .file_is_public } "
315+ )
303316 return HttpResponseRedirect (get_redirect_url (item ))
317+
318+ logger .warning (
319+ f"{ datetime .now (timezone .utc ).isoformat ()} file download denied: username={ username } path={ request .path } is_public={ self .file_is_public } "
320+ )
304321 return HttpResponse ("Permission denied" , status = status .HTTP_403_FORBIDDEN )
You can’t perform that action at this time.
0 commit comments