Skip to content

Commit f730b64

Browse files
authored
Add post_logout_redirect_uris field to application views (#1285)
* Add post_logout_redirect_uris field to application views * Update docs
1 parent f28ca84 commit f730b64

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
### Added
2020
* #1273 Add caching of loading of OIDC private key.
21+
* #1285 Add post_logout_redirect_uris field in application views.
2122

2223
- ### Fixed
2324
* #1284 Allow to logout whith no id_token_hint even if the browser session already expired

docs/templates.rst

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ This template gets passed the following template context variables:
165165
- ``client_type``
166166
- ``authorization_grant_type``
167167
- ``redirect_uris``
168+
- ``post_logout_redirect_uris``
168169

169170
.. caution::
170171
In the default implementation this template in extended by `application_registration_form.html`_.
@@ -184,6 +185,7 @@ This template gets passed the following template context variable:
184185
- ``client_type``
185186
- ``authorization_grant_type``
186187
- ``redirect_uris``
188+
- ``post_logout_redirect_uris``
187189

188190
.. note::
189191
In the default implementation this template extends `application_form.html`_.

oauth2_provider/templates/oauth2_provider/application_detail.html

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ <h3 class="block-center-heading">{{ application.name }}</h3>
3030
<p><b>{% trans "Redirect Uris" %}</b></p>
3131
<textarea class="input-block-level" readonly>{{ application.redirect_uris }}</textarea>
3232
</li>
33+
34+
<li>
35+
<p><b>{% trans "Post Logout Redirect Uris" %}</b></p>
36+
<textarea class="input-block-level" readonly>{{ application.post_logout_redirect_uris }}</textarea>
37+
</li>
3338
</ul>
3439

3540
<div class="btn-toolbar">

oauth2_provider/views/application.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def get_form_class(self):
3737
"client_type",
3838
"authorization_grant_type",
3939
"redirect_uris",
40+
"post_logout_redirect_uris",
4041
"algorithm",
4142
),
4243
)
@@ -95,6 +96,7 @@ def get_form_class(self):
9596
"client_type",
9697
"authorization_grant_type",
9798
"redirect_uris",
99+
"post_logout_redirect_uris",
98100
"algorithm",
99101
),
100102
)

tests/test_application_views.py

+38
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_application_registration_user(self):
4646
"client_secret": "client_secret",
4747
"client_type": Application.CLIENT_CONFIDENTIAL,
4848
"redirect_uris": "http://example.com",
49+
"post_logout_redirect_uris": "http://other_example.com",
4950
"authorization_grant_type": Application.GRANT_AUTHORIZATION_CODE,
5051
"algorithm": "",
5152
}
@@ -55,13 +56,22 @@ def test_application_registration_user(self):
5556

5657
app = get_application_model().objects.get(name="Foo app")
5758
self.assertEqual(app.user.username, "foo_user")
59+
app = Application.objects.get()
60+
self.assertEquals(app.name, form_data["name"])
61+
self.assertEquals(app.client_id, form_data["client_id"])
62+
self.assertEquals(app.redirect_uris, form_data["redirect_uris"])
63+
self.assertEquals(app.post_logout_redirect_uris, form_data["post_logout_redirect_uris"])
64+
self.assertEquals(app.client_type, form_data["client_type"])
65+
self.assertEquals(app.authorization_grant_type, form_data["authorization_grant_type"])
66+
self.assertEquals(app.algorithm, form_data["algorithm"])
5867

5968

6069
class TestApplicationViews(BaseTest):
6170
def _create_application(self, name, user):
6271
app = Application.objects.create(
6372
name=name,
6473
redirect_uris="http://example.com",
74+
post_logout_redirect_uris="http://other_example.com",
6575
client_type=Application.CLIENT_CONFIDENTIAL,
6676
authorization_grant_type=Application.GRANT_AUTHORIZATION_CODE,
6777
user=user,
@@ -93,9 +103,37 @@ def test_application_detail_owner(self):
93103

94104
response = self.client.get(reverse("oauth2_provider:detail", args=(self.app_foo_1.pk,)))
95105
self.assertEqual(response.status_code, 200)
106+
self.assertContains(response, self.app_foo_1.name)
107+
self.assertContains(response, self.app_foo_1.redirect_uris)
108+
self.assertContains(response, self.app_foo_1.post_logout_redirect_uris)
109+
self.assertContains(response, self.app_foo_1.client_type)
110+
self.assertContains(response, self.app_foo_1.authorization_grant_type)
96111

97112
def test_application_detail_not_owner(self):
98113
self.client.login(username="foo_user", password="123456")
99114

100115
response = self.client.get(reverse("oauth2_provider:detail", args=(self.app_bar_1.pk,)))
101116
self.assertEqual(response.status_code, 404)
117+
118+
def test_application_udpate(self):
119+
self.client.login(username="foo_user", password="123456")
120+
121+
form_data = {
122+
"client_id": "new_client_id",
123+
"redirect_uris": "http://new_example.com",
124+
"post_logout_redirect_uris": "http://new_other_example.com",
125+
"client_type": Application.CLIENT_PUBLIC,
126+
"authorization_grant_type": Application.GRANT_OPENID_HYBRID,
127+
}
128+
response = self.client.post(
129+
reverse("oauth2_provider:update", args=(self.app_foo_1.pk,)),
130+
data=form_data,
131+
)
132+
self.assertRedirects(response, reverse("oauth2_provider:detail", args=(self.app_foo_1.pk,)))
133+
134+
self.app_foo_1.refresh_from_db()
135+
self.assertEquals(self.app_foo_1.client_id, form_data["client_id"])
136+
self.assertEquals(self.app_foo_1.redirect_uris, form_data["redirect_uris"])
137+
self.assertEquals(self.app_foo_1.post_logout_redirect_uris, form_data["post_logout_redirect_uris"])
138+
self.assertEquals(self.app_foo_1.client_type, form_data["client_type"])
139+
self.assertEquals(self.app_foo_1.authorization_grant_type, form_data["authorization_grant_type"])

0 commit comments

Comments
 (0)