bugfix
This commit is contained in:
parent
335d4daf8d
commit
dab165396d
@ -15,6 +15,13 @@ from appPublic.jsonConfig import getConfig
|
||||
from appPublic.rsawrap import RSA
|
||||
from appPublic.app_logger import AppLogger
|
||||
|
||||
def get_client_ip(obj, request):
|
||||
ip = request.headers.get('X-Forwarded-For')
|
||||
if not ip:
|
||||
ip = request.remote
|
||||
request['client_ip'] = ip
|
||||
return ip
|
||||
|
||||
class AuthAPI(AppLogger):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@ -35,13 +42,6 @@ class AuthAPI(AppLogger):
|
||||
self.getPrivateKey()
|
||||
return self.rsaEngine.decode(self.privatekey,cdata)
|
||||
|
||||
def get_client_ip(self, request):
|
||||
ip = request.headers.get('X-Forwarded-For')
|
||||
if not ip:
|
||||
ip = request.remote
|
||||
request['client_ip'] = ip
|
||||
return ip
|
||||
|
||||
async def setupAuth(self,app):
|
||||
# setup session middleware in aiohttp fashion
|
||||
|
||||
@ -65,14 +65,14 @@ class AuthAPI(AppLogger):
|
||||
|
||||
def _new_ticket(self, request, user_id):
|
||||
client_uuid = request.headers.get('client_uuid')
|
||||
ip = self.get_client_ip(request)
|
||||
ip = self._get_ip(request)
|
||||
if not ip:
|
||||
ip = request.remote
|
||||
valid_until = int(time.time()) + self._max_age
|
||||
print(f'hack: my _new_ticket() called ...remote {ip=}, {client_uuid=}')
|
||||
return self._ticket.new(user_id, valid_until=valid_until, client_ip=ip, user_data=client_uuid)
|
||||
|
||||
TktAuthentication._get_ip = self.get_client_ip
|
||||
TktAuthentication._get_ip = get_client_ip
|
||||
TktAuthentication._new_ticket = _new_ticket
|
||||
policy = auth.SessionTktAuthentication(urandom(32), session_max_time,
|
||||
reissue_time=session_reissue_time,
|
||||
@ -92,7 +92,7 @@ class AuthAPI(AppLogger):
|
||||
user = await auth.get_auth(request)
|
||||
is_ok = await self.checkUserPermission(user, path)
|
||||
t2 = time.time()
|
||||
ip = self.get_client_ip(request)
|
||||
ip = get_client_ip(None, request)
|
||||
if is_ok:
|
||||
try:
|
||||
ret = await handler(request)
|
||||
|
Loading…
Reference in New Issue
Block a user