Merge pull request #162 from wojtek-fliposports/fix_after_login_hook_doc
rename OIDC_POST_END_SESSION_HOOK to OIDC_AFTER_END_SESSION_HOOK
This commit is contained in:
commit
d5111ed881
6 changed files with 22 additions and 10 deletions
|
@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
##### Added
|
||||
- Signals when user accept/decline the authorization page.
|
||||
- `OIDC_POST_END_SESSION_HOOK` setting for additional bussiness logic
|
||||
- `OIDC_AFTER_END_SESSION_HOOK` setting for additional business logic
|
||||
- Feature granttype password
|
||||
|
||||
##### Fixed
|
||||
|
|
|
@ -36,6 +36,18 @@ Return ``None`` if you want to continue with the flow.
|
|||
The typical situation will be checking some state of the user or maybe redirect him somewhere.
|
||||
With request you have access to all OIDC parameters. Remember that if you redirect the user to another place then you need to take him back to the authorize endpoint (use ``request.get_full_path()`` as the value for a "next" parameter).
|
||||
|
||||
OIDC_AFTER_END_SESSION_HOOK
|
||||
===========================
|
||||
|
||||
OPTIONAL. ``str``. A string with the location of your function. Provide a way to plug into the log out process just before calling Django's log out function, typically to perform some business logic.
|
||||
|
||||
Default is::
|
||||
|
||||
def default_after_end_session_hook(request, id_token=None, post_logout_redirect_uri=None, state=None, client=None, next_page=None):
|
||||
return None
|
||||
|
||||
Return ``None`` if you want to continue with the flow.
|
||||
|
||||
OIDC_CODE_EXPIRE
|
||||
================
|
||||
|
||||
|
|
|
@ -85,9 +85,9 @@ def default_after_userlogin_hook(request, user, client):
|
|||
return None
|
||||
|
||||
|
||||
def default_post_end_session_hook(request, id_token=None, post_logout_redirect_uri=None, state=None, client=None, next_page=None):
|
||||
def default_after_end_session_hook(request, id_token=None, post_logout_redirect_uri=None, state=None, client=None, next_page=None):
|
||||
"""
|
||||
Default function for setting OIDC_POST_END_SESSION_HOOK.
|
||||
Default function for setting OIDC_AFTER_END_SESSION_HOOK.
|
||||
|
||||
:param request: Django request object
|
||||
:type request: django.http.HttpRequest
|
||||
|
|
|
@ -31,12 +31,12 @@ class DefaultSettings(object):
|
|||
return 'oidc_provider.lib.utils.common.default_after_userlogin_hook'
|
||||
|
||||
@property
|
||||
def OIDC_POST_END_SESSION_HOOK(self):
|
||||
def OIDC_AFTER_END_SESSION_HOOK(self):
|
||||
"""
|
||||
OPTIONAL. Provide a way to plug into the end session process just before calling
|
||||
Django's logout function, typically to perform some business logic.
|
||||
"""
|
||||
return 'oidc_provider.lib.utils.common.default_post_end_session_hook'
|
||||
return 'oidc_provider.lib.utils.common.default_after_end_session_hook'
|
||||
|
||||
@property
|
||||
def OIDC_CODE_EXPIRE(self):
|
||||
|
|
|
@ -46,9 +46,9 @@ class EndSessionTestCase(TestCase):
|
|||
response = self.client.get(self.url, query_params)
|
||||
self.assertRedirects(response, self.LOGOUT_URL, fetch_redirect_response=False)
|
||||
|
||||
@mock.patch(settings.get('OIDC_POST_END_SESSION_HOOK'))
|
||||
@mock.patch(settings.get('OIDC_AFTER_END_SESSION_HOOK'))
|
||||
def test_call_post_end_session_hook(self, hook_function):
|
||||
self.client.get(self.url)
|
||||
self.assertTrue(hook_function.called, 'OIDC_POST_END_SESSION_HOOK should be called')
|
||||
self.assertTrue(hook_function.call_count == 1, 'OIDC_POST_END_SESSION_HOOK should be called once but was {}'.format(hook_function.call_count))
|
||||
self.assertTrue(hook_function.called, 'OIDC_AFTER_END_SESSION_HOOK should be called')
|
||||
self.assertTrue(hook_function.call_count == 1, 'OIDC_AFTER_END_SESSION_HOOK should be called once but was {}'.format(hook_function.call_count))
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ class EndSessionView(View):
|
|||
client = None
|
||||
|
||||
next_page = settings.get('LOGIN_URL')
|
||||
post_end_session_hook = settings.get('OIDC_POST_END_SESSION_HOOK', import_str=True)
|
||||
after_end_session_hook = settings.get('OIDC_AFTER_END_SESSION_HOOK', import_str=True)
|
||||
|
||||
if id_token_hint:
|
||||
client_id = client_id_from_id_token(id_token_hint)
|
||||
|
@ -287,7 +287,7 @@ class EndSessionView(View):
|
|||
except Client.DoesNotExist:
|
||||
pass
|
||||
|
||||
post_end_session_hook(
|
||||
after_end_session_hook(
|
||||
request=request,
|
||||
id_token=id_token_hint,
|
||||
post_logout_redirect_uri=post_logout_redirect_uri,
|
||||
|
|
Loading…
Reference in a new issue