update buckler middleware
This commit is contained in:
parent
342c1a7c87
commit
3d71b50384
|
@ -16,8 +16,8 @@ async def buckler_session(request, handler):
|
||||||
Verifies the user with the configured Buckler app and retrieves any
|
Verifies the user with the configured Buckler app and retrieves any
|
||||||
session data they may have. Redirects them to the login page otherwise.
|
session data they may have. Redirects them to the login page otherwise.
|
||||||
"""
|
"""
|
||||||
user_id = request.cookies.get('userid')
|
user_id = request.cookies.get('userid', '')
|
||||||
user_sid = request.cookies.get('session')
|
user_sid = request.cookies.get('session', '')
|
||||||
|
|
||||||
url = config.buckler['url'] + '/get_session'
|
url = config.buckler['url'] + '/get_session'
|
||||||
params = {
|
params = {
|
||||||
|
@ -30,7 +30,14 @@ async def buckler_session(request, handler):
|
||||||
async with session.get(url, params=params) as resp:
|
async with session.get(url, params=params) as resp:
|
||||||
data = await resp.json()
|
data = await resp.json()
|
||||||
if data.get('error'):
|
if data.get('error'):
|
||||||
raise web.HTTPFound(location=config.buckler['login_url'])
|
resp = web.HTTPFound(config.buckler['login_url'])
|
||||||
|
resp.set_cookie(
|
||||||
|
'redirect',
|
||||||
|
request.url,
|
||||||
|
secure=True,
|
||||||
|
httponly=True)
|
||||||
|
#samesite='strict')
|
||||||
|
raise resp
|
||||||
request['session'] = data['session_data']
|
request['session'] = data['session_data']
|
||||||
request['meta'] = data['meta']
|
request['meta'] = data['meta']
|
||||||
|
|
||||||
|
@ -51,11 +58,13 @@ async def buckler_session(request, handler):
|
||||||
max_age=30*24*60*60,
|
max_age=30*24*60*60,
|
||||||
secure=True,
|
secure=True,
|
||||||
httponly=True)
|
httponly=True)
|
||||||
|
#samesite='strict')
|
||||||
resp.set_cookie(
|
resp.set_cookie(
|
||||||
'session',
|
'session',
|
||||||
user_sid,
|
user_sid,
|
||||||
max_age=30*24*60*60,
|
max_age=30*24*60*60,
|
||||||
secure=True,
|
secure=True,
|
||||||
httponly=True)
|
httponly=True)
|
||||||
|
#samesite='strict')
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user