User.signup - Python API

Lets users sign up themselves with the system. In Python, a zato.sso.SignupCtx object is created and filled in with details of the user about to be signed up.

Input is validated according to configuration from sso.conf. All callback services are executed if the user has been created successfully.

On output, confirmation token is returned that may be used to let a user know via email that their account has been prepared but needs to be confirmed by clicking on a selected link. The token is URL-safe and 192-bit strong.

SignupCtx has the following properties:

Name Datatype Optional? Notes
username string Username to create
password string User’s password
email string Yes User’s email
current_app string Name of the application the user is signing up through
app_list list A list of applications that the user wants to sign up to (all must exist in sso.conf)

API

self.sso.user.signup

signup(self, cid, ctx, current_app, remote_addr)

Signs up users with the SSO system.

Parameters:
  • cid (string) – Correlation ID used by audit log
  • ctx (zato.sso.SignupCtx) – Signup configuration
  • current_app (string) – Name of application the current user is issuing the call from
  • remote_addr (string) – User’s remote address
Return type:

A confirmation token that may be used by the user to confirm that account’s creation

 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
29
30
31
32
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

# stdlib
from uuid import uuid4

# Zato
from zato.server.service import Service
from zato.sso import const, SignupCtx

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

        # Signup data
        username = 'my.username'
        email = 'my.username@example.com'
        password = uuid4().hex
        app_list = ['CRM']

        # Prepare the context object
        ctx = SignupCtx()
        ctx.username = username
        ctx.email = email
        ctx.password = password
        ctx.app_list = app_list

        # Sign up the user
        confirm_token = self.sso.user.signup(self.cid, ctx, 'CRM', '127.0.0.1')

        # Log the confirmation token received
        self.logger.info('Token: %s', confirm_token)
1
INFO - Token: v9IEOwbBr0JEsboKyleAp6yuKwIEzmJ0