Skip to content

Commit b704982

Browse files
authored
Merge pull request #406 from johngian/fix-405
Add configuration to opt in logout using GET
2 parents 5d775a8 + 8b67577 commit b704982

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

docs/settings.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,9 @@ of ``mozilla-django-oidc``.
257257
:default: False
258258

259259
Use HTTP Basic Authentication instead of sending the client secret in token request POST body.
260+
261+
.. py:attribute:: ALLOW_LOGOUT_GET_METHOD
262+
263+
:default: False
264+
265+
Allow using GET method to logout user

mozilla_django_oidc/views.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.contrib import auth
44
from django.core.exceptions import SuspiciousOperation
5-
from django.http import HttpResponseRedirect
5+
from django.http import HttpResponseRedirect, HttpResponseNotAllowed
66
from django.urls import reverse
77
from django.utils.crypto import get_random_string
88

@@ -202,7 +202,7 @@ def redirect_url(self):
202202
"""Return the logout url defined in settings."""
203203
return self.get_settings('LOGOUT_REDIRECT_URL', '/')
204204

205-
def get(self, request):
205+
def post(self, request):
206206
"""Log out the user."""
207207
logout_url = self.redirect_url
208208

@@ -218,6 +218,8 @@ def get(self, request):
218218

219219
return HttpResponseRedirect(logout_url)
220220

221-
def post(self, request):
221+
def get(self, request):
222222
"""Log out the user."""
223-
return self.get(request)
223+
if self.get_settings("ALLOW_LOGOUT_GET_METHOD", False):
224+
return self.post(request)
225+
return HttpResponseNotAllowed(["POST"])

0 commit comments

Comments
 (0)