Repository: privacyidea/privacyidea

Issue:
Generate passwords only with the contents of base58.
**Is your feature request related to a problem? Please describe.**

When passwords are generated (e.g. in the case of lost token), the passwords could look rather non-readable due to problematic charcters like zero, Ohs, lower "L" or upper "i"...
See https://en.wikipedia.org/wiki/Base58

**Describe the solution you'd like**

We should allow to set the policy at least in the lost token, to not only choose from upper charecters, lower characters and number, also choose from base58, which makes the password better readable.
We can simply fetch from the allowed list of characters.




Discussion:

Resolving patch:
diff --git a/privacyidea/lib/policy.py b/privacyidea/lib/policy.py
--- a/privacyidea/lib/policy.py
+++ b/privacyidea/lib/policy.py
@@ -1563,7 +1563,7 @@ def get_static_policy_definitions(scope=None):
             ACTION.LOSTTOKENPWCONTENTS: {
                 'type': 'str',
                 'desc': _('The contents of the temporary password, '
-                          'described by the characters C, c, n, s.')},
+                          'described by the characters C, c, n, s, 8.')},
             ACTION.LOSTTOKENVALID: {
                 'type': 'int',
                 'value': list(range(1, 61)),
diff --git a/privacyidea/lib/token.py b/privacyidea/lib/token.py
--- a/privacyidea/lib/token.py
+++ b/privacyidea/lib/token.py
@@ -1,6 +1,8 @@
 # -*- coding: utf-8 -*-
 #  privacyIDEA is a fork of LinOTP
 #
+#  2018-12-10 Cornelius Kölbel <cornelius.koelbel@netknights.it>
+#             Add Base58
 #  2018-01-21 Cornelius Kölbel <cornelius.koelbel@netknights.it>
 #             Add tokenkind
 #  2017-08-11 Cornelius Kölbel <cornelius.koelbel@netknights.it>
@@ -73,7 +75,7 @@
 from privacyidea.lib.decorators import (check_user_or_serial,
                                         check_copy_serials)
 from privacyidea.lib.tokenclass import TokenClass
-from privacyidea.lib.utils import generate_password, is_true
+from privacyidea.lib.utils import generate_password, is_true, BASE58
 from privacyidea.lib.log import log_with
 from privacyidea.models import (Token, Realm, TokenRealm, Challenge,
                                 MachineToken, TokenInfo)
@@ -1776,7 +1778,7 @@ def copy_token_realms(serial_from, serial_to):
 @log_with(log)
 @libpolicy(config_lost_token)
 def lost_token(serial, new_serial=None, password=None,
-               validity=10, contents="Ccns", pw_len=16, options=None):
+               validity=10, contents="8", pw_len=16, options=None):
     """
     This is the workflow to handle a lost token.
     The token <serial> is lost and will be disabled. A new token of type
@@ -1791,7 +1793,7 @@ def lost_token(serial, new_serial=None, password=None,
     :type validity: int
     :param contents: The contents of the generated password. "C": upper case
     characters, "c": lower case characters, "n": digits and "s": special
-    characters
+    characters, "8": base58
     :type contents: A string like "Ccn"
     :param pw_len: The length of the generated password
     :type pw_len: int
@@ -1824,6 +1826,8 @@ def lost_token(serial, new_serial=None, password=None,
             character_pool += string.digits
         if "s" in contents:
             character_pool += "!#$%&()*+,-./:;<=>?@[]^_"
+        if "8" in contents:
+            character_pool += BASE58
 
     if password is None:
         password = generate_password(size=pw_len, characters=character_pool)
diff --git a/privacyidea/lib/utils.py b/privacyidea/lib/utils.py
--- a/privacyidea/lib/utils.py
+++ b/privacyidea/lib/utils.py
@@ -66,6 +66,7 @@
 
 ENCODING = "utf-8"
 
+BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
 
 def check_time_in_range(time_range, check_time=None):
     """


Test patch: