Support Center
Both regular and super-users can access information about their own accounts using self.sso.user.get_current_user, which accepts current session's UST on input. Further, super-users may query for other users by the latter's ID with self.sso.user.get_user_by_id.
On out, a zato.sso.User object is returned which describes a given user with a range of attributes. Further, the object's .to_dict() method will serialize all the data to a Python dictionary.
Passwords are never returned regardless of user type.
get_current_user(self, cid, current_ust, current_app, remote_addr)
cid
: Correlation ID used by audit logcurrent_ust
: Current user's USTcurrent_app
: Name of application the current user is issuing the call fromremote_addr
: User's remote addressReturns
: A zato.sso.User object with attributes out of which only user_id and username are guaranteed to always exist. The rest is optional and additionally, some of attributes are set to meaningful values, if they exist at all, only if current user is a super-user.Accessible no matter the user type is:
Accessible to super-users only:
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class GetCurrentUser(Service):
def handle(self):
# Data obtained from request and/or WSGI environment
ust = 'gAAAAABalFycY50Budi...'
current_app = 'CRM'
remote_addr = '127.0.0.1'
# Get user by UST
user_info = self.sso.user.get_current_user(self.cid, ust, current_app, remote_addr)
# Log output for confirmation
self.logger.info(user_info.to_dict())
INFO - {
'user_id': 'zusrx2efj1q1h98n9q00tgx8scefv',
'username': 'regular1',
'display_name': 'John Doe',
'email': 'hello@example.com'
}
get_user_by_id(self, cid, user_id, current_ust, current_app, remote_addr)
Returns information about a user using that person's ID. Current user must be a super-user.
cid
: Correlation ID used by audit loguser_id
: User ID (another person or possibly current user)current_ust
: Current user's UST - must belong to a super-usercurrent_app
: Name of application current user is issuing the call fromremote_addr
: Current user's remote addressReturns
: Same as in self.sso.user.get_current_user