Skip to content
Snippets Groups Projects
Verified Commit 669e2bb5 authored by Peter Bolha's avatar Peter Bolha :ok_hand_tone1:
Browse files

fix: user token types calculation logic

parent 532f8d6d
No related branches found
No related tags found
1 merge request!60fix: user token types calculation logic
Pipeline #393167 passed
import argparse
import os
import re
from collections import defaultdict
from typing import List, Tuple, Optional, Pattern
import yaml
......@@ -128,18 +129,16 @@ def main():
mfa_active_tokens_attr_name = args.mfa_active_tokens_attr_name
adapters_manager = get_adapters_manager(args.perun_connector_config_path)
user_token_types = get_user_token_types()
current_user_id = ""
current_user_token_types = []
user_all_usable_tokens = defaultdict(list)
for privacyidea_user_id, token_type in user_token_types:
perun_user_id = parse_perun_user_id(perun_user_id_regex, privacyidea_user_id)
if perun_user_id and perun_user_id != current_user_id:
if current_user_id:
current_user_token_types.sort()
attr_to_set = {mfa_active_tokens_attr_name: current_user_token_types}
adapters_manager.set_user_attributes(int(perun_user_id), attr_to_set)
current_user_id = perun_user_id
current_user_token_types = []
current_user_token_types.append(token_type)
user_all_usable_tokens[perun_user_id].append(token_type)
for perun_user_id, token_types in user_all_usable_tokens.items():
token_types.sort()
attr_to_set = {mfa_active_tokens_attr_name: token_types}
adapters_manager.set_user_attributes(int(perun_user_id), attr_to_set)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment