Session.renew - Python API

Renews current session, returning its new expiration time on output (in UTC).

Note that the call will raise an exception if:

  • The session has already expired
  • The underlying user’s password has already expired

API

self.sso.user.session.renew

renew(self, cid, current_ust, current_app, remote_addr)

Creates a new super-user.

Parameters:
  • cid (string) – Correlation ID used by audit log
  • current_ust (string) – Current user’s UST, the one to renew
  • current_app (string) – Name of application the current user is issuing the call from
  • remote_addr (string) – Current user’s remote address
Return type:

expiration_time - A datetime object representing the session’s new expiration time

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

from __future__ import absolute_import, division, print_function, unicode_literals

# Zato
from zato.server.service import Service

class RenewSession(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)

        # Renew the session
        expiration = self.sso.user.session.renew(self.cid, session.ust, current_app, remote_addr)

        # Log result (in UTC)
        self.logger.info('Expiration: %s, %s', expiration, type(expiration))
1
INFO - Expiration: 2018-03-14 15:24:39.361223, <type 'datetime.datetime'>