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.

API

self.sso.user.session.get

get(self, cid, target_ust, current_ust, current_app, remote_addr)

Returns details of a session pointed to by target_ust.

Parameters:
  • cid (string) – Correlation ID used by audit log
  • target_ust (string) – UST of the session to return details of
  • current_ust (string) – Current user’s UST (must belong to a super-user)
  • current_app (string) – Name of application the current user is issuing the call from
  • remote_addr (string) – Current user’s remote address
Return type:

exists - A dictionary of metadata describing the session from target_ust. All keys and values are always returned on output:

Key Datatype Notes
creation_time datetime When the session was created, in UTC
expiration_time datetime When the session will expire, in UTC
remote_addr string From what remote address the session was created
user_agent string Using what user agent the session was created

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

# 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)
1
2
3
4
INFO - creation_time   2018-03-14 16:27:55
INFO - expiration_time 2018-03-14 17:27:55
INFO - remote_addr     127.0.0.1
INFO - user_agent      Firefox 139.0