oauth_provider: log authorisation to audit

This commit is contained in:
Jens Langhammer 2018-12-16 17:09:14 +01:00
parent 9e289e9937
commit 7a62bf9829
No known key found for this signature in database
GPG Key ID: BEBC05297D92821B
1 changed files with 5 additions and 1 deletions

View File

@ -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)