SuperUser.create - Python API

Creates a new super-user. Current user's UST must belong to an already existing super-user.

self.sso.user.create_super_user

create_super_user(self, cid, data, current_ust, current_app, remote_addr)

  • cid: Correlation ID used by audit log
  • data: A dictionary of values to create a new user from. On output, the dictionary will be enriched with defaults assigned during the creation process.
  • current_ust: Current user's UST
  • current_app: Name of application the current user is issuing the call from
  • remote_addr: User's remote address
  • Returns: None - the input 'data' dictionary is modified in place.

The 'data' dictionary is in the format described below:

KeyOptionalDefaultNotes
username------Must be unique among all users
passwordYes192 bitsIf not given, a random string of 192 bits will be assigned
password_must_changeYesFalse
display_nameYes---Display name
first_nameYes---First name
middle_nameYes---Middle name
last_nameYes---Last name
emailYes---User's email
is_lockedYes---Should the account be locked upon creation, i.e. logging in will not be possible
sign_up_statusYesfinalUser's initial signup status, by default it is 'final' meaning the user is fully signed up
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

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

        # Request metadata
        current_ust = 'gAAAAABalo6MX7z62Pyo416OFfDJ-4MuTMmSpIqAmvOXWckG...'
        current_app = 'CRM'
        remote_addr = '127.0.0.1'

        # Creation data
        data = {
          'username': 'admin1',
          'password': 'Zp=VZMdZ2-!S6EJ5~sh5cfMiZ7--,aD3Nbya ^8j',
          'password_must_change': True,
          'display_name': 'My User'
        }

        # Create user
        self.sso.user.create_super_user(self.cid, data, current_ust, current_app, remote_addr)

        # The input dictionary will have been updated in place
        self.logger.info(data)
INFO {
  'display_name': 'My User',
  'is_active': True,
  'is_internal': False,
  'is_super_user': True,
  'is_approved': True,
  'is_locked': False,
  'password_expiry': datetime.datetime(2020, 2, 28, 11, 33, 13, 359733),
  'password_must_change': True,
  'password_last_set': datetime.datetime(2023, 2, 28, 11, 33, 13, 359733),
  'sign_up_time': datetime.datetime(2023, 2, 28, 11, 33, 13, 359733),
  'sign_up_status': 'final',
  'username': 'admin1',
  'user_id': 'zusr5znzppxrwp8dp8qsp5g8khes86'
}