Skip to content

Commit 3f7ecd7

Browse files
committed
Add Tests and Documentation for option to disable http post logout URIs
1 parent 30cd41d commit 3f7ecd7

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

docs/advanced_topics.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ logo, acceptance of some user agreement and so on.
2020
* :attr:`client_id` The client identifier issued to the client during the registration process as described in :rfc:`2.2`
2121
* :attr:`user` ref to a Django user
2222
* :attr:`redirect_uris` The list of allowed redirect uri. The string consists of valid URLs separated by space
23+
* :attr:`post_logout_redirect_uris` The list of allowed redirect uris after an RP initiated logout. The string consists of valid URLs separated by space
2324
* :attr:`client_type` Client type as described in :rfc:`2.1`
2425
* :attr:`authorization_grant_type` Authorization flows available to the Application
2526
* :attr:`client_secret` Confidential secret issued to the client during the registration process as described in :rfc:`2.2`

docs/management_commands.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The ``createapplication`` management command provides a shortcut to create a new
3838
3939
usage: manage.py createapplication [-h] [--client-id CLIENT_ID] [--user USER]
4040
[--redirect-uris REDIRECT_URIS]
41+
[--post-logout-redirect-uris POST_LOGOUT_REDIRECT_URIS]
4142
[--client-secret CLIENT_SECRET]
4243
[--name NAME] [--skip-authorization]
4344
[--algorithm ALGORITHM] [--version]
@@ -64,6 +65,9 @@ The ``createapplication`` management command provides a shortcut to create a new
6465
--redirect-uris REDIRECT_URIS
6566
The redirect URIs, this must be a space separated
6667
string e.g 'URI1 URI2'
68+
--post-logout-redirect-uris POST_LOGOUT_REDIRECT_URIS
69+
The post logout redirect URIs, this must be a space
70+
separated string e.g 'URI1 URI2'
6771
--client-secret CLIENT_SECRET
6872
The secret for this application
6973
--name NAME The name this application

oauth2_provider/management/commands/createapplication.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def add_arguments(self, parser):
3737
type=str,
3838
help="The redirect URIs, this must be a space separated string e.g 'URI1 URI2'",
3939
)
40+
parser.add_argument(
41+
"--post-logout-redirect-uris",
42+
type=str,
43+
help="The post logout redirect URIs, this must be a space separated string e.g 'URI1 URI2'",
44+
default="",
45+
)
4046
parser.add_argument(
4147
"--client-secret",
4248
type=str,

oauth2_provider/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class AbstractApplication(models.Model):
5252
* :attr:`user` ref to a Django user
5353
* :attr:`redirect_uris` The list of allowed redirect uri. The string
5454
consists of valid URLs separated by space
55+
* :attr:`post_logout_redirect_uris` The list of allowed redirect uris after
56+
an RP initiated logout. The string
57+
consists of valid URLs separated by space
5558
* :attr:`client_type` Client type as described in :rfc:`2.1`
5659
* :attr:`authorization_grant_type` Authorization flows available to the
5760
Application

tests/presets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
OIDC_SETTINGS_RP_LOGOUT = deepcopy(OIDC_SETTINGS_RW)
3232
OIDC_SETTINGS_RP_LOGOUT["OIDC_RP_INITIATED_LOGOUT_ENABLED"] = True
3333
OIDC_SETTINGS_RP_LOGOUT["OIDC_RP_INITIATED_LOGOUT_ALWAYS_PROMPT"] = False
34+
OIDC_SETTINGS_RP_LOGOUT_STRICT_REDIRECT_URI = deepcopy(OIDC_SETTINGS_RP_LOGOUT)
35+
OIDC_SETTINGS_RP_LOGOUT_STRICT_REDIRECT_URI["OIDC_RP_INITIATED_LOGOUT_STRICT_REDIRECT_URIS"] = True
3436
OIDC_SETTINGS_RP_LOGOUT_DENY_EXPIRED = deepcopy(OIDC_SETTINGS_RP_LOGOUT)
3537
OIDC_SETTINGS_RP_LOGOUT_DENY_EXPIRED["OIDC_RP_INITIATED_LOGOUT_ACCEPT_EXPIRED_TOKENS"] = False
3638
OIDC_SETTINGS_RP_LOGOUT_KEEP_TOKENS = deepcopy(OIDC_SETTINGS_RP_LOGOUT)

tests/test_oidc_views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,23 @@ def test_rp_initiated_logout_get_id_token_missmatch_client_id(
343343
def test_rp_initiated_logout_public_client_redirect_client_id(
344344
loggend_in_client, oidc_non_confidential_tokens, public_application, rp_settings
345345
):
346+
rsp = loggend_in_client.get(
347+
reverse("oauth2_provider:rp-initiated-logout"),
348+
data={
349+
"id_token_hint": oidc_non_confidential_tokens.id_token,
350+
"client_id": public_application.client_id,
351+
"post_logout_redirect_uri": "http://other.org",
352+
},
353+
)
354+
assert rsp.status_code == 302
355+
assert not is_logged_in(loggend_in_client)
356+
357+
358+
@pytest.mark.django_db
359+
def test_rp_initiated_logout_public_client_strict_redirect_client_id(
360+
loggend_in_client, oidc_non_confidential_tokens, public_application, oauth2_settings
361+
):
362+
oauth2_settings.update(presets.OIDC_SETTINGS_RP_LOGOUT_STRICT_REDIRECT_URI)
346363
rsp = loggend_in_client.get(
347364
reverse("oauth2_provider:rp-initiated-logout"),
348365
data={

0 commit comments

Comments
 (0)