##// END OF EJS Templates
audit-logs: use specific web/api calls....
marcink -
r1806:99a19fa8 default
parent child Browse files
Show More
@@ -1179,11 +1179,10 b' def delete_repo(request, apiuser, repoid'
1179 repo = audit_logger.RepoWrap(repo_id=None,
1179 repo = audit_logger.RepoWrap(repo_id=None,
1180 repo_name=repo.repo_name)
1180 repo_name=repo.repo_name)
1181
1181
1182 audit_logger.store(
1182 audit_logger.store_api(
1183 action='repo.delete',
1183 action='repo.delete',
1184 action_data={'repo_data': repo_data,
1184 action_data={'data': repo_data},
1185 'source': audit_logger.SOURCE_API},
1185 user=apiuser, repo=repo)
1186 user=apiuser, repo=repo, commit=False)
1187
1186
1188 ScmModel().mark_for_invalidation(repo_name, delete=True)
1187 ScmModel().mark_for_invalidation(repo_name, delete=True)
1189 Session().commit()
1188 Session().commit()
@@ -172,7 +172,7 b' class LoginView(BaseAppView):'
172 username=self.request.params.get('username'),
172 username=self.request.params.get('username'),
173 ip_addr=self.request.remote_addr)
173 ip_addr=self.request.remote_addr)
174 action_data = {'user_agent': self.request.user_agent}
174 action_data = {'user_agent': self.request.user_agent}
175 audit_logger.store(
175 audit_logger.store_web(
176 action='user.login.success', action_data=action_data,
176 action='user.login.success', action_data=action_data,
177 user=audit_user, commit=True)
177 user=audit_user, commit=True)
178
178
@@ -191,7 +191,7 b' class LoginView(BaseAppView):'
191 username=self.request.params.get('username'),
191 username=self.request.params.get('username'),
192 ip_addr=self.request.remote_addr)
192 ip_addr=self.request.remote_addr)
193 action_data = {'user_agent': self.request.user_agent}
193 action_data = {'user_agent': self.request.user_agent}
194 audit_logger.store(
194 audit_logger.store_web(
195 action='user.login.failure', action_data=action_data,
195 action='user.login.failure', action_data=action_data,
196 user=audit_user, commit=True)
196 user=audit_user, commit=True)
197 return render_ctx
197 return render_ctx
@@ -211,7 +211,7 b' class LoginView(BaseAppView):'
211 log.info('Deleting session for user: `%s`', auth_user)
211 log.info('Deleting session for user: `%s`', auth_user)
212
212
213 action_data = {'user_agent': self.request.user_agent}
213 action_data = {'user_agent': self.request.user_agent}
214 audit_logger.store(
214 audit_logger.store_web(
215 action='user.logout', action_data=action_data,
215 action='user.logout', action_data=action_data,
216 user=auth_user, commit=True)
216 user=auth_user, commit=True)
217 self.session.delete()
217 self.session.delete()
@@ -364,7 +364,8 b' class LoginView(BaseAppView):'
364
364
365 action_data = {'email': user_email,
365 action_data = {'email': user_email,
366 'user_agent': self.request.user_agent}
366 'user_agent': self.request.user_agent}
367 audit_logger.store(action='user.password.reset_request',
367 audit_logger.store_web(
368 action='user.password.reset_request',
368 action_data=action_data,
369 action_data=action_data,
369 user=self._rhodecode_user, commit=True)
370 user=self._rhodecode_user, commit=True)
370 return HTTPFound(self.request.route_path('reset_password'))
371 return HTTPFound(self.request.route_path('reset_password'))
@@ -87,7 +87,7 b' class RepoSettingsPermissionsView(RepoAp'
87 'updated': changes['updated'],
87 'updated': changes['updated'],
88 'deleted': changes['deleted'],
88 'deleted': changes['deleted'],
89 }
89 }
90 audit_logger.store(
90 audit_logger.store_web(
91 'repo.edit.permissions', action_data=action_data,
91 'repo.edit.permissions', action_data=action_data,
92 user=self._rhodecode_user, repo=self.db_repo)
92 user=self._rhodecode_user, repo=self.db_repo)
93
93
@@ -162,7 +162,7 b' class RepoSettingsView(RepoAppView):'
162 RepoModel().update(self.db_repo, **validated_updates)
162 RepoModel().update(self.db_repo, **validated_updates)
163 ScmModel().mark_for_invalidation(new_repo_name)
163 ScmModel().mark_for_invalidation(new_repo_name)
164
164
165 audit_logger.store(
165 audit_logger.store_web(
166 'repo.edit', action_data={'old_data': old_values},
166 'repo.edit', action_data={'old_data': old_values},
167 user=self._rhodecode_user, repo=self.db_repo)
167 user=self._rhodecode_user, repo=self.db_repo)
168
168
@@ -99,11 +99,10 b' class RepoSettingsView(RepoAppView):'
99
99
100 repo = audit_logger.RepoWrap(repo_id=None,
100 repo = audit_logger.RepoWrap(repo_id=None,
101 repo_name=self.db_repo.repo_name)
101 repo_name=self.db_repo.repo_name)
102 audit_logger.store(
102 audit_logger.store_web(
103 action='repo.delete',
103 action='repo.delete',
104 action_data={'repo_data': repo_data,
104 action_data={'data': repo_data},
105 'source': audit_logger.SOURCE_WEB},
105 user=self._rhodecode_user, repo=repo)
106 user=self._rhodecode_user, repo=repo, commit=False)
107
106
108 ScmModel().mark_for_invalidation(self.db_repo_name, delete=True)
107 ScmModel().mark_for_invalidation(self.db_repo_name, delete=True)
109 h.flash(
108 h.flash(
@@ -101,7 +101,7 b' class StripView(RepoAppView):'
101 commit['rev'], c.repo_info.repo_name, user))
101 commit['rev'], c.repo_info.repo_name, user))
102 data[commit['rev']] = True
102 data[commit['rev']] = True
103
103
104 audit_logger.store(
104 audit_logger.store_web(
105 action='repo.commit.strip',
105 action='repo.commit.strip',
106 action_data={'commit_id': commit['rev']},
106 action_data={'commit_id': commit['rev']},
107 repo=self.db_repo,
107 repo=self.db_repo,
@@ -189,9 +189,9 b' class RepoGroupsController(BaseControlle'
189 repo_group_data = repo_group.get_api_data()
189 repo_group_data = repo_group.get_api_data()
190 _new_group_name = form_result['group_name_full']
190 _new_group_name = form_result['group_name_full']
191
191
192 audit_logger.store(
192 audit_logger.store_web(
193 action='repo_group.create',
193 action='repo_group.create',
194 action_data={'repo_group_data': repo_group_data},
194 action_data={'data': repo_group_data},
195 user=c.rhodecode_user, commit=True)
195 user=c.rhodecode_user, commit=True)
196
196
197 repo_group_url = h.link_to(
197 repo_group_url = h.link_to(
@@ -251,7 +251,7 b' class RepoGroupsController(BaseControlle'
251 gr_name = form_result['group_name']
251 gr_name = form_result['group_name']
252 new_gr = RepoGroupModel().update(group_name, form_result)
252 new_gr = RepoGroupModel().update(group_name, form_result)
253
253
254 audit_logger.store(
254 audit_logger.store_web(
255 'repo_group.edit', action_data={'old_data': old_values},
255 'repo_group.edit', action_data={'old_data': old_values},
256 user=c.rhodecode_user)
256 user=c.rhodecode_user)
257
257
@@ -303,10 +303,9 b' class RepoGroupsController(BaseControlle'
303 old_values = gr.get_api_data()
303 old_values = gr.get_api_data()
304 RepoGroupModel().delete(group_name)
304 RepoGroupModel().delete(group_name)
305
305
306 audit_logger.store(
306 audit_logger.store_web(
307 'repo_group.delete',
307 'repo_group.delete',
308 action_data={'old_data': old_values,
308 action_data={'old_data': old_values},
309 'source': audit_logger.SOURCE_WEB},
310 user=c.rhodecode_user)
309 user=c.rhodecode_user)
311
310
312 Session().commit()
311 Session().commit()
@@ -395,9 +394,8 b' class RepoGroupsController(BaseControlle'
395 'added': changes['added'],
394 'added': changes['added'],
396 'updated': changes['updated'],
395 'updated': changes['updated'],
397 'deleted': changes['deleted'],
396 'deleted': changes['deleted'],
398 'source': audit_logger.SOURCE_WEB
399 }
397 }
400 audit_logger.store(
398 audit_logger.store_web(
401 'repo_group.edit.permissions', action_data=action_data,
399 'repo_group.edit.permissions', action_data=action_data,
402 user=c.rhodecode_user)
400 user=c.rhodecode_user)
403
401
@@ -814,7 +814,7 b' class FilesController(BaseRepoController'
814 archive = cached_archive_path
814 archive = cached_archive_path
815
815
816 # store download action
816 # store download action
817 audit_logger.store(
817 audit_logger.store_web(
818 action='repo.archive.download',
818 action='repo.archive.download',
819 action_data={'user_agent': request.user_agent,
819 action_data={'user_agent': request.user_agent,
820 'archive_name': archive_name,
820 'archive_name': archive_name,
@@ -149,7 +149,7 b' def store(action, user, action_data=None'
149 audit_logger.store(
149 audit_logger.store(
150 action='repo.edit', user=self._rhodecode_user)
150 action='repo.edit', user=self._rhodecode_user)
151 audit_logger.store(
151 audit_logger.store(
152 action='repo.delete', action_data={'repo_data': repo_data},
152 action='repo.delete', action_data={'data': repo_data},
153 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'))
153 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'))
154
154
155 # repo action
155 # repo action
@@ -179,7 +179,7 b' def create_repo(form_data, cur_user):'
179 repo_id = repo.repo_id
179 repo_id = repo.repo_id
180 repo_data = repo.get_api_data()
180 repo_data = repo.get_api_data()
181
181
182 audit_logger.store(
182 audit_logger.store_web(
183 action='repo.create',
183 action='repo.create',
184 action_data={'data': repo_data},
184 action_data={'data': repo_data},
185 user=cur_user,
185 user=cur_user,
@@ -274,7 +274,7 b' def create_repo_fork(form_data, cur_user'
274
274
275 repo_id = repo.repo_id
275 repo_id = repo.repo_id
276 repo_data = repo.get_api_data()
276 repo_data = repo.get_api_data()
277 audit_logger.store(
277 audit_logger.store_web(
278 action='repo.fork',
278 action='repo.fork',
279 action_data={'data': repo_data},
279 action_data={'data': repo_data},
280 user=cur_user,
280 user=cur_user,
General Comments 0
You need to be logged in to leave comments. Login now