Disable automatic re-execution of command after pending authentication.

It's possible to enable it again globally by
'freeipa/config':`rpc_retry_auth`.

https://fedorahosted.org/freeipa/ticket/4374

# Additional info:
This ticket is in 4.0 stabilization milestone. I don't think it's the best fit. It has a potential to break things. It's also harder to test because integration tests don't test it - one has to remove session cookie every time and then react appropriately.

It's also first usage of ./config module (other items there are not used). This module was originally implemented to contain global webui config which could be overwritten by config configured on server, ie for disabling paging in large deployments. The server part doesn't exist yet. Other reason is to split ipa.js into more single-purpose files.
--
Petr Vobornik
From fa28c0fbf5451802d640fcb9a9cd09fc1b8082cc Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Tue, 22 Jul 2014 10:49:38 +0200
Subject: [PATCH] webui: review pending operation after expired session

Disable automatic re-execution of command after pending authentication.

It's possible to enable it again globally by
'freeipa/config':`rpc_retry_auth`.

https://fedorahosted.org/freeipa/ticket/4374
---
 install/ui/src/freeipa/config.js |  8 +++++++-
 install/ui/src/freeipa/ipa.js    |  1 +
 install/ui/src/freeipa/rpc.js    | 19 +++++++++++++++----
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/install/ui/src/freeipa/config.js b/install/ui/src/freeipa/config.js
index 632bc136df5e342b7f2d99d8615b3d0d3645b772..08083908f5d727c7ee948dc6aa9dff9042e5a60b 100644
--- a/install/ui/src/freeipa/config.js
+++ b/install/ui/src/freeipa/config.js
@@ -70,8 +70,14 @@ define([], function() {
             dataType: 'json',
             async: true,
             processData: false
-        }
+        },
 
+        /**
+         * Retry RPC command after successful authentication if it failed or was not
+         * executed because of authentication issue.
+         * @type {Boolean}
+         */
+        rpc_retry_auth: false
     };
 
     return config;
diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js
index 0fb35632e9147c901f1a961c978d6ed8ff84aa2e..63bab26f2dfa365a9b8ac4c1431982eddf6d8fa0 100644
--- a/install/ui/src/freeipa/ipa.js
+++ b/install/ui/src/freeipa/ipa.js
@@ -137,6 +137,7 @@ var IPA = function () {
         var batch = rpc.batch_command({
             name: 'ipa_init',
             retry: false,
+            retry_auth: true,
             on_success: function() {
                 that.init_metadata({
                     on_success: params.on_success,
diff --git a/install/ui/src/freeipa/rpc.js b/install/ui/src/freeipa/rpc.js
index 784f7555b7c2d9a7dbf6b28d7b5f2e0a030f58aa..ada6aeb8db3dc8accd2b5ce49cd2b289bd806f35 100644
--- a/install/ui/src/freeipa/rpc.js
+++ b/install/ui/src/freeipa/rpc.js
@@ -25,12 +25,13 @@
 define([
     'dojo/_base/lang',
     './auth',
+    './config',
     './ipa',
     './text',
     './util',
     'exports'
    ],
-   function(lang, auth, IPA, text, util, rpc /*exports*/) {
+   function(lang, auth, config, IPA, text, util, rpc /*exports*/) {
 
 /**
  * Call an IPA command over JSON-RPC.
@@ -93,7 +94,14 @@ rpc.command = function(spec) {
      * error handling without any dialog.
      * @property {Boolean} retry=true
      */
-    that.retry = typeof spec.retry == 'undefined' ? true : spec.retry;
+    that.retry = spec.retry === undefined ? true : spec.retry;
+
+    /**
+     * Retry command after successful authentication if it failed or was not
+     * executed because of authentication issue.
+     * @property {Boolean} retry_auth=false
+     */
+    that.retry_auth = spec.retry_auth === undefined ? config.rpc_retry_auth : spec.retry_auth;
 
     /** @property {string} error_message Default error message */
     that.error_message = text.get(spec.error_message || '@i18n:dialogs.batch_error_message', 'Some operations failed.');
@@ -229,7 +237,9 @@ rpc.command = function(spec) {
 
             auth.current.set_authenticated(false, '');
             auth.current.authenticate().then(function() {
-                that.execute();
+                if (that.retry_auth) {
+                    that.execute();
+                }
             });
         }
 
@@ -541,7 +551,8 @@ rpc.batch_command = function(spec) {
             method: that.method,
             args: that.args,
             options: that.options,
-            retry: that.retry
+            retry: that.retry,
+            retry_auth: that.retry_auth
         });
 
         command.on_success = that.batch_command_on_success;
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to