def get_random_password()

in lib/cognito_util.py [0:0]


def get_random_password(length):
  randomSource = string.ascii_letters + string.digits + COGNITO_SPECIAL_CHARACTERS
  
  # At least one of each type
  password = random.choice(string.ascii_lowercase)
  password += random.choice(string.ascii_uppercase)
  password += random.choice(string.digits)
  password += random.choice(COGNITO_SPECIAL_CHARACTERS)

  # Fill the remainder with random characters 
  for i in range(length-4):
    password += random.choice(randomSource)

  # Shuffle
  passwordList = list(password)
  random.SystemRandom().shuffle(passwordList)
  password = ''.join(passwordList)
  
  return password