Logs a user into the system. On success, returns session info, including a UST (user session token) that represents a particular session of that user with the SSO environment.
On invalid input raises zato.sso.api.ValidationError which contains details in the form of status and sub-status codes pointing to specific erroneous conditions.
Note that only users whose approval_status is "approved" will be able to log in, otherwise an error will be raised.
login(self, cid, username, password, current_app, remote_addr, user_agent=None, has_remote_addr=False, has_user_agent=False, new_password='', totp_code=None)
cid: Correlation ID used by audit log
username: Name of a user to log in
password: That user's password
current_app: Name of application the user is logging in from
remote_addr: User's remote address
user_agent: User agent string, e.g. "Firefox 345"
totp_code: Optional TOTP code if user has two-factor authentication enabled
has_remote_addr: Should be set to True if input remote_addr was sent explicitly by user in JSON or to False if it was extracted by the caller (e.g. from the WSGI environment)
has_user_agent: Should be set to True if input user_agent was sent explicitly by user in JSON or to False if it was extracted by the caller (e.g. from the WSGI environment)
new_password: User's new password - should be sent in if the password for user is currently required to be changed
Returns: A zato.sso.session.SessionInfo object with attributes:
username- taken from input
ust- UST, in encrypted form
user_id- ID of the newly logged in user
creation_time- when was the session created, in UTC
expiration_time- when will the session expire, in UTC
# -*- coding: utf-8 -*- # Zato from zato.server.service import Service class Login(Service): def handle(self): username = 'regular1' password = '0Z-XQCZ8sK1oeP9Ft8YeQgKxUDhM34HE' current_app = 'CRM' remote_addr = '127.0.0.1' user_agent = 'Firefox 139.0' session_info = self.sso.user.login(self.cid, username, password, current_app, remote_addr, user_agent) self.logger.info('UST %s', session_info.ust) self.logger.info('Created %s', session_info.creation_time.isoformat()) self.logger.info('Expires %s', session_info.expiration_time.isoformat())