diff --git a/oidc_provider/signals.py b/oidc_provider/signals.py new file mode 100644 index 0000000..679417c --- /dev/null +++ b/oidc_provider/signals.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from django.dispatch import Signal + + +user_accept_consent = Signal(providing_args=['user', 'client', 'scope']) +user_decline_consent = Signal(providing_args=['user', 'client', 'scope']) diff --git a/oidc_provider/views.py b/oidc_provider/views.py index bf2e1af..6bf142f 100644 --- a/oidc_provider/views.py +++ b/oidc_provider/views.py @@ -42,6 +42,7 @@ from oidc_provider.models import ( RSAKey, ) from oidc_provider import settings +from oidc_provider import signals logger = logging.getLogger(__name__) @@ -131,10 +132,14 @@ class AuthorizeView(View): authorize.validate_params() if not request.POST.get('allow'): + signals.user_decline_consent.send(self.__class__, user=request.user, client=authorize.client, scope=authorize.params['scope']) + raise AuthorizeError(authorize.params['redirect_uri'], 'access_denied', authorize.grant_type) + signals.user_accept_consent.send(self.__class__, user=request.user, client=authorize.client, scope=authorize.params['scope']) + # Save the user consent given to the client. authorize.set_client_user_consent()