Skip to content
Prev Previous commit
Next Next commit
Do not pollute the session
  • Loading branch information
katzlbt committed Nov 19, 2021
commit 663b6f718d9e1ec1c591598c9c0ca7dadc5f2ec7
4 changes: 2 additions & 2 deletions velruse/providers/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def login(self, request):
"""Initiate a facebook login"""
scope = request.POST.get('scope', self.scope)
display = request.POST.get('display', self.display)
request.session['state'] = state = uuid.uuid4().hex
request.session['velruse.state'] = state = uuid.uuid4().hex
fb_url = flat_url(
'https://www.facebook.com/dialog/oauth/',
# We refer to an API call made without specifying a version as an unversioned call. An unversioned call will always point to the oldest available version.
Expand All @@ -91,7 +91,7 @@ def login(self, request):

def callback(self, request):
"""Process the facebook redirect"""
sess_state = request.session.get('state')
sess_state = request.session.pop('velruse.state', None)
req_state = request.GET.get('state')
if not sess_state or sess_state != req_state:
raise CSRFError(
Expand Down
2 changes: 1 addition & 1 deletion velruse/providers/google_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def login(self, request):

def callback(self, request):
"""Process the google redirect"""
sess_state = request.session.get('velruse.state')
sess_state = request.session.pop('velruse.state', None)
req_state = request.GET.get('state')
if not sess_state or sess_state != req_state:
raise CSRFError(
Expand Down