Repository: privacyidea/privacyidea

Issue:
Remove undocumented `aladdin_hashlib` parameter from `token/load/` endpoint
The `token/load/` endpoint currently also accepts a parameter `aladdin_hashlib` which overwrites any given hash algorithm from the parsed data.
We should remove the parameter (which is not documented anyway) and re-evaluate the usage of the `default_hashlib` parameter in [`import_token`](https://github.com/privacyidea/privacyidea/blob/6e2ed66ea6ae01dec0068f705502f5d9786c8cb2/privacyidea/lib/token.py#L943).
This is somehow related to #2257


Discussion:

Resolving patch:
diff --git a/privacyidea/api/token.py b/privacyidea/api/token.py
--- a/privacyidea/api/token.py
+++ b/privacyidea/api/token.py
@@ -921,7 +921,6 @@ def loadtokens_api(filename=None):
     known_types = ['aladdin-xml', 'oathcsv', "OATH CSV", 'yubikeycsv',
                    'Yubikey CSV', 'pskc']
     file_type = getParam(request.all_data, "type", required)
-    hashlib = getParam(request.all_data, "aladdin_hashlib")
     aes_validate_mac = getParam(request.all_data, "pskcValidateMAC", default='check_fail_hard')
     aes_psk = getParam(request.all_data, "psk")
     aes_password = getParam(request.all_data, "password")
@@ -990,8 +989,7 @@ def loadtokens_api(filename=None):
 
         import_token(serial,
                      TOKENS[serial],
-                     tokenrealms=tokenrealms,
-                     default_hashlib=hashlib)
+                     tokenrealms=tokenrealms)
 
     g.audit_object.log({'info': u"{0!s}, {1!s} (imported: {2:d})".format(file_type,
                                                            token_file,
diff --git a/privacyidea/lib/token.py b/privacyidea/lib/token.py
--- a/privacyidea/lib/token.py
+++ b/privacyidea/lib/token.py
@@ -940,7 +940,7 @@ def _gen_serial(_prefix, _tokennum):
 
 
 @log_with(log)
-def import_token(serial, token_dict, default_hashlib=None, tokenrealms=None):
+def import_token(serial, token_dict, tokenrealms=None):
     """
     This function is used during the import of a PSKC file.
 
@@ -959,8 +959,6 @@ def import_token(serial, token_dict, default_hashlib=None, tokenrealms=None):
             }
 
     :type token_dict: dict
-    :param default_hashlib: Set the given hashlib as default
-    :type default_hashlib: str
     :param tokenrealms: List of realms to set as realms of the token
     :type tokenrealms: list
     :return: the token object
@@ -978,9 +976,6 @@ def import_token(serial, token_dict, default_hashlib=None, tokenrealms=None):
                         token_dict.get("user").get("realm"),
                         token_dict.get("user").get("resolver"))
 
-    if default_hashlib and default_hashlib != "auto":
-        init_param['hashlib'] = default_hashlib
-
     # Imported tokens are usually hardware tokens
     token = init_token(init_param, user=user_obj,
                        tokenrealms=tokenrealms,
@@ -1081,8 +1076,7 @@ def init_token(param, user=None, tokenrealms=None,
     if user is not None and user.login != "":
         tokenobject.add_user(user)
 
-    upd_params = param
-    tokenobject.update(upd_params)
+    tokenobject.update(param)
 
     try:
         # Save the token to the database


Test patch: