From 7a62bf9829fef0c68e26075cee517134ef2939b6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 16 Dec 2018 17:09:14 +0100 Subject: [PATCH] oauth_provider: log authorisation to audit --- passbook/oauth_provider/views/oauth2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/passbook/oauth_provider/views/oauth2.py b/passbook/oauth_provider/views/oauth2.py index c5c38629d..99d2e271e 100644 --- a/passbook/oauth_provider/views/oauth2.py +++ b/passbook/oauth_provider/views/oauth2.py @@ -6,6 +6,7 @@ from django.shortcuts import get_object_or_404, redirect, reverse from django.utils.translation import ugettext as _ from oauth2_provider.views.base import AuthorizationView +from passbook.audit.models import AuditEntry from passbook.core.views.access import AccessMixin from passbook.core.views.utils import LoadingView, PermissionDeniedView from passbook.oauth_provider.models import OAuth2Provider @@ -57,6 +58,9 @@ class PassbookAuthorizationView(AccessMixin, AuthorizationView): def form_valid(self, form): # User has clicked on "Authorize" - # TODO: Create Audit log entry + AuditEntry.create( + action=AuditEntry.ACTION_AUTHORIZE_APPLICATION, + request=self.request, + app=str(self._application)) LOGGER.debug('user %s authorized %s', self.request.user, self._application) return super().form_valid(form)