Add initial signals logic.

This commit is contained in:
Ignacio Fiorentino 2016-12-01 16:20:34 -03:00
parent 8d77634417
commit 5242f0841e
2 changed files with 11 additions and 0 deletions

6
oidc_provider/signals.py Normal file
View file

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

View file

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