Session.get - Python API

Returns details of a user session from target_ust, provided that the session exists, has not expired, and that its user's password has not expired. Only super-users are allowed to invoke this API.

self.sso.user.session.get

get(self, cid, target_ust, current_ust, current_app, remote_addr, user_agent=None)

  • cid: Correlation ID used by audit log
  • target_ust: UST of the session to return details of
  • current_ust: Current user's UST (must belong to a super-user)
  • current_app: Name of application the current user is issuing the call from
  • remote_addr: Current user's remote address
  • user_agent: User agent string
  • Returns: A dictionary of metadata describing the session from target_ust. All keys and values are always returned on output.

Each dictionary returned is in the format described below:

KeyDatatypeNotes
creation_timedatetimeWhen the session was created, in UTC
expiration_timedatetimeWhen the session will expire, in UTC
remote_addrstringFrom what remote address the session was created
user_agentstringUsing what user agent the session was created
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class GetSession(Service):
    def handle(self):

      username = 'admin1'
      password = 'abxqDJpXMVXYEO8NOGx9nVZvv4xSew9-'
      current_app = 'CRM'
      remote_addr = '127.0.0.1'
      user_agent = 'Firefox 139.0'

      # Log current user
      session = self.sso.user.login(username, password, current_app, remote_addr, user_agent)

      # Get UST
      ust = session.ust

      # Get current user's session
      session = self.sso.user.session.get(self.cid, ust, ust, current_app, remote_addr)

      # Log result
      for key, value in sorted(session.to_dict().items()):
          self.logger.info('%s %s', key.ljust(15), value)
INFO - creation_time   2023-03-14 16:27:55
INFO - expiration_time 2023-03-14 17:27:55
INFO - remote_addr     127.0.0.1
INFO - user_agent      Firefox 139.0