##// END OF EJS Templates
audit-logger: added entry for archive download.
marcink -
r1743:71b6a673 default
parent child Browse files
Show More
@@ -35,7 +35,7 b' from webob.exc import HTTPNotFound, HTTP'
35 35
36 36 from rhodecode.controllers.utils import parse_path_ref
37 37 from rhodecode.lib import diffs, helpers as h, caches
38 from rhodecode.lib.compat import OrderedDict
38 from rhodecode.lib import audit_logger
39 39 from rhodecode.lib.codeblocks import (
40 40 filenode_as_lines_tokens, filenode_as_annotated_lines_tokens)
41 41 from rhodecode.lib.utils import jsonify, action_logger
@@ -813,6 +813,26 b' class FilesController(BaseRepoController'
813 813 shutil.move(archive, cached_archive_path)
814 814 archive = cached_archive_path
815 815
816 # store download action
817 action_logger(user=c.rhodecode_user,
818 action='user_downloaded_archive:%s' % archive_name,
819 repo=repo_name, ipaddr=self.ip_addr, commit=True)
820
821 audit_logger.store(
822 action='repo.archive.download',
823 action_data={'user_agent': request.user_agent,
824 'archive_name': archive_name,
825 'archive_spec': fname,
826 'archive_cached': use_cached_archive},
827 user=c.rhodecode_user,
828 repo=dbrepo,
829 commit=True
830 )
831
832 response.content_disposition = str(
833 'attachment; filename=%s' % archive_name)
834 response.content_type = str(content_type)
835
816 836 def get_chunked_archive(archive):
817 837 with open(archive, 'rb') as stream:
818 838 while True:
@@ -826,14 +846,6 b' class FilesController(BaseRepoController'
826 846 break
827 847 yield data
828 848
829 # store download action
830 action_logger(user=c.rhodecode_user,
831 action='user_downloaded_archive:%s' % archive_name,
832 repo=repo_name, ipaddr=self.ip_addr, commit=True)
833 response.content_disposition = str(
834 'attachment; filename=%s' % archive_name)
835 response.content_type = str(content_type)
836
837 849 return get_chunked_archive(archive)
838 850
839 851 @LoginRequired()
@@ -39,7 +39,8 b' ACTIONS = {'
39 39 'repo.add': {},
40 40 'repo.edit': {},
41 41 'repo.edit.permissions': {},
42 'repo.commit.strip': {}
42 'repo.commit.strip': {},
43 'repo.archive.download': {},
43 44 }
44 45
45 46
@@ -97,14 +98,31 b' def store('
97 98
98 99 from rhodecode.lib import audit_logger
99 100
100 audit_logger.store(action='repo.edit', user=self._rhodecode_user)
101 audit_logger.store(action='repo.delete', user=audit_logger.UserWrap(username='itried-to-login', ip_addr='8.8.8.8'))
101 audit_logger.store(
102 action='repo.edit', user=self._rhodecode_user)
103 audit_logger.store(
104 action='repo.delete',
105 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'))
106
107 # repo action
108 audit_logger.store(
109 action='repo.delete',
110 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'),
111 repo=audit_logger.RepoWrap(repo_name='some-repo'))
112
113 # repo action, when we know and have the repository object already
114 audit_logger.store(
115 action='repo.delete',
116 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'),
117 repo=repo_object)
102 118
103 119 # without an user ?
104 audit_user = audit_logger.UserWrap(
120 audit_logger.store(
121 action='user.login.failure',
122 user=audit_logger.UserWrap(
105 123 username=self.request.params.get('username'),
106 ip_addr=self.request.remote_addr)
107 audit_logger.store(action='user.login.failure', user=audit_user)
124 ip_addr=self.request.remote_addr))
125
108 126 """
109 127 from rhodecode.lib.utils2 import safe_unicode
110 128 from rhodecode.lib.auth import AuthUser
General Comments 0
You need to be logged in to leave comments. Login now