diff options
author | Alexander Bokovoy <abokovoy@redhat.com> | 2013-05-06 17:10:56 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-05-06 20:44:00 +0200 |
commit | 03cdc22c940e82199c2afa8b4a69708237ee0a7a (patch) | |
tree | 110721c903eb032702f9980e354eec848fcbaef1 /install | |
parent | aedded862dce2c8450d0eef5eca3d854166af06b (diff) | |
download | freeipa.git-03cdc22c940e82199c2afa8b4a69708237ee0a7a.tar.gz freeipa.git-03cdc22c940e82199c2afa8b4a69708237ee0a7a.tar.xz freeipa.git-03cdc22c940e82199c2afa8b4a69708237ee0a7a.zip |
Resolve SIDs in Web UI
Introduce new command, 'trust-resolve', to aid resolving SIDs to names
in the Web UI.
The command uses new SSSD interface, nss_idmap, to resolve actual SIDs.
SSSD caches resolved data so that future requests to resolve same SIDs
are returned from a memory cache.
Web UI code is using Dojo/Deferred to deliver result of SID resolution
out of band. Once resolved names are available, they replace SID values.
Since Web UI only shows ~20 records per page, up to 20 SIDs are resolved
at the same time. They all sent within the single request to the server.
https://fedorahosted.org/freeipa/ticket/3302
Diffstat (limited to 'install')
-rw-r--r-- | install/ui/src/freeipa/association.js | 50 | ||||
-rw-r--r-- | install/ui/src/freeipa/entity.js | 2 | ||||
-rw-r--r-- | install/ui/src/freeipa/group.js | 3 | ||||
-rw-r--r-- | install/ui/src/freeipa/widget.js | 30 |
4 files changed, 79 insertions, 6 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index d33ec874..71ee71d4 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -23,6 +23,7 @@ * the AssociationList elements; IT NEEDS IT'S OWN CODE! */ define([ + 'dojo/Deferred', './ipa', './jquery', './navigation', @@ -31,7 +32,7 @@ define([ './text', './search', './dialog'], - function(IPA, $, navigation, phases, reg, text) { + function(Deferred, IPA, $, navigation, phases, reg, text) { IPA.associator = function (spec) { @@ -1364,6 +1365,53 @@ IPA.attribute_facet = function(spec, no_init) { return that; }; +IPA.sid_facet = function(spec, no_init) { + + spec.name = spec.name || 'sid_facet'; + + var that = IPA.attribute_facet(spec, no_init); + + that.load_records = function(value) { + var xlate = {}; + var sidxlate_command = IPA.command({ + entity: 'trust', + method: 'resolve', + options: { + sids: '' + } + }); + sidxlate_command.on_success = function(data, text_status, xhr) { + for (var i=0; i< data.result.result.length; i++) { + var entry = data.result.result[i]; + if (entry.sid[0] in xlate) { + xlate[entry.sid[0]].resolve(entry.name[0]); + } + } + }; + that.table.empty(); + + if (value.length === 0) return; + + var sids = []; + for (var i=0; i< value.length; i++) { + var sid = value[i][that.attribute]; + var deferred = new Deferred(); + value[i][that.attribute] = { + promise: deferred.promise, + temp: sid + }; + xlate[sid] = deferred; + sids.push(sid); + that.add_record(value[i]); + } + sidxlate_command.options.sids = sids; + sidxlate_command.execute(); + }; + + return that; +}; + + IPA.attr_read_only_evaluator = function(spec) { spec.name = spec.name || 'attr_read_only_evaluator'; diff --git a/install/ui/src/freeipa/entity.js b/install/ui/src/freeipa/entity.js index 427d300e..0d0564d1 100644 --- a/install/ui/src/freeipa/entity.js +++ b/install/ui/src/freeipa/entity.js @@ -662,4 +662,4 @@ registry.builder.post_ops.push( exp.entity_post_ops.deleter_dialog); return exp; -});
\ No newline at end of file +}); diff --git a/install/ui/src/freeipa/group.js b/install/ui/src/freeipa/group.js index 0408d0bc..5e8cdf99 100644 --- a/install/ui/src/freeipa/group.js +++ b/install/ui/src/freeipa/group.js @@ -112,6 +112,7 @@ return { }, { $type: 'attribute', + $factory: IPA.sid_facet, name: 'member_external', attribute: 'ipaexternalmember', tab_label: 'External', @@ -280,4 +281,4 @@ exp.register = function() { phases.on('registration', exp.register); return exp; -});
\ No newline at end of file +}); diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 0fe046e4..8f1208e0 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -1404,9 +1404,6 @@ IPA.column = function (spec) { } that.setup = function(container, record, suppress_link) { - - container.empty(); - var value = record[that.name]; var type; if (that.formatter) { @@ -1414,7 +1411,34 @@ IPA.column = function (spec) { value = that.formatter.format(value); type = that.formatter.type; } + + var promise, temp = ''; + if (value && typeof value.then === 'function') promise = value; + if (value && value.promise && typeof value.promise.then === 'function') { + promise = value.promise; + temp = value.temp || ''; + } + + if (promise) { + var fulfilled = false; + promise.then(function(val) { + fulfilled = true; + that.set_value(container, val, type, suppress_link); + }); + + if (fulfilled) return; + // val obj can contain temporal value which is displayed + // until promise is fulfilled + value = temp; + } + + that.set_value(container, value, type, suppress_link); + }; + + that.set_value = function(container, value, type, suppress_link) { + value = value ? value.toString() : ''; + container.empty(); var c; if (that.link && !suppress_link) { |