7575 type: dict
7676 index:
7777 description:
78- - Priority order of the execution.
78+ - Index order of the execution.
7979 type: int
80+ priority:
81+ description:
82+ - Priority order of the execution. Defaults to index if not specified.
83+ type: int
84+
8085 state:
8186 description:
8287 - Control if the authentication flow must exists or not.
@@ -385,35 +390,7 @@ def add_diff_entry(new_exec, old_exec, before, after):
385390 after ["executions" ][exec_key ]["authenticationConfig" ] = before ["executions" ][exec_key ]["authenticationConfig" ] | after ["executions" ][exec_key ]["authenticationConfig" ]
386391
387392
388- def correct_execution_index (kc , realm , existing_execs , new_exec ):
389- """
390- Shifts the execution matching new_exec on the server side to match the
391- new_exec's index and applies the server side modifications on the local
392- objects
393-
394- :param kc: keycloak instance to use for server side modifications
395- :param realm: realm on which modifications are applied
396- :param existing_execs: current state of the server side executions
397- (as returned by kc.get_executions_representation). Is modified to
398- reflect server side changes
399- :param new_exec: expected execution configuration
400- """
401- current_exec = [e for e in existing_execs if e ["id" ] == new_exec ["id" ]][0 ]
402- shift = current_exec ["index" ] - new_exec ["index" ]
403- if shift == 0 :
404- return existing_execs
405-
406- kc .change_execution_priority (new_exec ["id" ], shift , realm = realm )
407- # Align the local representation with the server side changes
408- for e in existing_execs :
409- if e ["level" ] == new_exec ["level" ] and \
410- e ["index" ] >= new_exec ["index" ] and \
411- e ["index" ] < current_exec ["index" ]:
412- e ["index" ] += 1
413- current_exec ["index" ] = new_exec ["index" ]
414-
415-
416- def create_or_update_executions (kc , config , check_mode , new_flow = False , realm = 'master' , kc26 = False ):
393+ def create_or_update_executions (kc , config , check_mode , new_flow = False , realm = 'master' ):
417394 """
418395 Create or update executions for an authentication flow.
419396 :param kc: Keycloak API access.
@@ -500,11 +477,10 @@ def create_or_update_executions(kc, config, check_mode, new_flow=False, realm='m
500477 else :
501478 levels_indices [current_level ] += 1
502479 new_exec ["index" ] = levels_indices [current_level ]
503- if kc26 and ("priority" not in new_exec or new_exec ["priority" ] is None ):
504- new_exec ["priority" ] = new_exec ["index" ]
505480
506- if not kc26 :
507- del new_exec ["priority" ]
481+ # Add priority from index if none were specified
482+ if ("priority" not in new_exec or new_exec ["priority" ] is None ):
483+ new_exec ["priority" ] = new_exec ["index" ]
508484
509485 # Check if there exists an execution with same name/providerID, at the same level as new execution
510486 exec_index = find_exec_in_executions (new_exec , existing_executions , changed_executions_ids )
@@ -559,9 +535,6 @@ def create_or_update_executions(kc, config, check_mode, new_flow=False, realm='m
559535 add_error_line (err_msg_lines = err_msg , err_msg = "wrong index" , flow = config ["alias" ],
560536 exec_name = get_identifier (new_exec ), expected = new_exec ["index" ],
561537 actual = existing_exec ["index" ])
562- if not check_mode and not kc26 :
563- correct_execution_index (
564- kc , realm , existing_executions , new_exec )
565538 else :
566539 if not check_mode :
567540 created_execution , existing_executions = \
@@ -576,14 +549,6 @@ def create_or_update_executions(kc, config, check_mode, new_flow=False, realm='m
576549 kc , flow_alias_parent , new_exec , check_mode ,
577550 realm )
578551
579- # Keycloak creates new executions with the lowest
580- # priority
581- if not new_flow and not kc26 :
582- # If the main flow is new, we don't have to
583- # push executions up.
584- correct_execution_index (
585- kc , realm , existing_executions , new_exec )
586-
587552 auth_conf = new_exec .get ("authenticationConfig" )
588553 if auth_conf is not None :
589554 kc .add_authenticationConfig_to_execution (
@@ -641,8 +606,7 @@ def main():
641606 priority = dict (type = 'int' )
642607 )),
643608 state = dict (choices = ["absent" , "present" , "exact" ], default = 'present' ),
644- force = dict (type = 'bool' , default = False ),
645- kc26 = dict (type = 'bool' , default = False )
609+ force = dict (type = 'bool' , default = False )
646610 )
647611
648612 argument_spec .update (meta_args )
@@ -666,7 +630,6 @@ def main():
666630 realm = module .params .get ('realm' )
667631 state = module .params .get ('state' )
668632 force = module .params .get ('force' )
669- kc26 = module .params .get ('kc26' )
670633
671634 new_auth_repr = {
672635 "alias" : module .params .get ("alias" ),
@@ -714,7 +677,7 @@ def main():
714677 module .fail_json (** result )
715678
716679 # Configure the executions for the flow
717- create_or_update_executions (kc = kc , config = new_auth_repr , check_mode = module .check_mode or module .params ["check" ], new_flow = True , realm = realm , kc26 = kc26 )
680+ create_or_update_executions (kc = kc , config = new_auth_repr , check_mode = module .check_mode or module .params ["check" ], new_flow = True , realm = realm )
718681
719682 # Get executions created
720683 exec_repr = kc .get_executions_representation (config = new_auth_repr , realm = realm )
@@ -747,7 +710,7 @@ def main():
747710
748711 # Configure the executions for the flow
749712 changed , diff , err_msg = create_or_update_executions (kc = kc , config = new_auth_repr , \
750- check_mode = module .check_mode or module .params ["check" ], new_flow = False , realm = realm , kc26 = kc26 )
713+ check_mode = module .check_mode or module .params ["check" ], new_flow = False , realm = realm )
751714 result ['changed' ] |= changed
752715
753716 if module ._diff :
0 commit comments