Skip to content
Snippets Groups Projects
Commit f7371b7f authored by Pavel Břoušek's avatar Pavel Břoušek
Browse files

chore: merge branch 'peterbolha/PRX-371/fix_sync_script' into 'main'

fix: user token types calculation logic

Closes PRX-371

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