You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/03/29 13:10:46 UTC

[incubator-ponymail-foal] 09/19: add remote ip to session object

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 49bea18d86f7aae6664732af570f5ea8692745b9
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Mar 29 11:28:50 2021 +0200

    add remote ip to session object
    
    this will be used for audit logs
---
 server/plugins/session.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/server/plugins/session.py b/server/plugins/session.py
index 4ccd526..b10c8f3 100644
--- a/server/plugins/session.py
+++ b/server/plugins/session.py
@@ -68,6 +68,7 @@ class SessionObject:
     last_accessed: int
     credentials: typing.Optional[SessionCredentials]
     database: typing.Optional[plugins.database.Database]
+    remote: str
     server: plugins.server.BaseServer
 
     def __init__(self, server: plugins.server.BaseServer, **kwargs):
@@ -80,6 +81,7 @@ class SessionObject:
             self.credentials = None
             self.cookie = str(uuid.uuid4())
             self.cid = None
+            self.remote = "??"
         else:
             self.last_accessed = kwargs.get("last_accessed", 0)
             self.credentials = SessionCredentials(kwargs.get("credentials"))
@@ -115,6 +117,7 @@ async def get_session(
             # In case the session is used twice within the same loop
             session = copy.copy(x_session)
             session.database = await server.dbpool.get()
+            session.remote = request.remote
 
             # Do we need to update the timestamp in ES?
             if (now - session.last_accessed) > FOAL_SAVE_SESSION_INTERVAL:
@@ -126,6 +129,7 @@ async def get_session(
     # If not in local memory, start a new session object
     session = SessionObject(server)
     session.database = await server.dbpool.get()
+    session.remote = request.remote
 
     # If a cookie was supplied, look for a session object in ES
     if session_id and session.database: