diff options
author | Pavel Vomacka <pvomacka@redhat.com> | 2016-10-05 10:20:25 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-03-14 10:40:10 +0100 |
commit | 93a7f4c88db159664664bd82d1d00e5e0033ac22 (patch) | |
tree | 674a88beb110eee0cf28629b9e0bb7772af1418c | |
parent | ec63456b7c1fba6bd8d9073e63c27ef685f08c60 (diff) | |
download | freeipa-93a7f4c88db159664664bd82d1d00e5e0033ac22.tar.gz freeipa-93a7f4c88db159664664bd82d1d00e5e0033ac22.tar.xz freeipa-93a7f4c88db159664664bd82d1d00e5e0033ac22.zip |
Possibility to skip checking writable according to metadata
Useful in association tables which need to ignore object's metadata flags.
Association tables don't check right at all. They check them only when
'acl_param' is set in association table field spec. In case that checking metadata
needs to be turned on even for Association table, then set 'check_writable_from_metadata'
true value in spec.
Part of: https://fedorahosted.org/freeipa/ticket/5426
Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r-- | install/ui/src/freeipa/association.js | 19 | ||||
-rw-r--r-- | install/ui/src/freeipa/field.js | 64 |
2 files changed, 65 insertions, 18 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index 02f990a7f..7954ddc4e 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -827,12 +827,31 @@ IPA.association_table_field = function (spec) { spec = spec || {}; + /** + * Turn off decision whether the field is writable according to metadata. + * The source of rights will be only ACLs. + * + * @property {Boolean} + */ + spec.check_writable_from_metadata = spec.check_writable_from_metadata === undefined ? + false : spec.check_writable_from_metadata; + var that = IPA.field(spec); that.load = function(data) { that.values = that.adapter.load(data); that.widget.update(that.values); that.widget.unselect_all(); + + if (!!that.acl_param) { + var record = that.adapter.get_record(data); + that.load_writable(record); + that.handle_acl(); + } + }; + + that.handle_acl = function() { + if (!that.writable) that.widget.set_enabled(false); }; that.refresh = function() { diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index 5df2f6c9a..76ce2533a 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -96,6 +96,16 @@ field.field = IPA.field = function(spec) { that.param = spec.param || spec.name; /** + * Some fields needs to skip checking whether they are writable or not + * in metadata. It is possible by setting this option to true. + * Field example: association_table_field + * + * @property {string} + */ + that.check_writable_from_metadata = spec.check_writable_from_metadata !== undefined ? + spec.check_writable_from_metadata : true; + + /** * Entity param which provides access control rights * * - defaults to `param` @@ -459,10 +469,43 @@ field.field = IPA.field = function(spec) { }; /** + * Evaluate if field is writable according to ACL in record and field + * configuration. Updates `writable` property. + * + * Not writable: + * + * - primary keys + * - with 'no_update' metadata flag + */ + that.load_writable_from_metadata = function(writable) { + if (that.metadata) { + if (that.metadata.primary_key) { + writable = false; + } + + // In case that field has set always_writable attribute, then + // 'no_update' flag is ignored in WebUI. It is done because of + // commands like user-{add,remove}-certmap. They operate with user's + // attribute, which cannot be changed using user-mod, but only + // using command user-{add,remove}-certmap. Therefore it has set + // 'no_update' flag, but we need to show 'Add', 'Remove' buttons in + // WebUI. + if (that.metadata.flags && + array.indexOf(that.metadata.flags, 'no_update') > -1 && + !that.always_writable) { + writable = false; + } + } + + return writable; + }; + + + /** * Evaluate if field is writable according to ACL in record and field * configuration. Updates `writable` property. * - * Not writable: + * Not writable (checked in method that.load_writable_from_metadata()): * * - primary keys * - with 'no_update' metadata flag @@ -487,23 +530,8 @@ field.field = IPA.field = function(spec) { return has; } - if (that.metadata) { - if (that.metadata.primary_key) { - writable = false; - } - - // In case that field has set always_writable attribute, then - // 'no_update' flag is ignored in WebUI. It is done because of - // commands like user-{add,remove}-certmap. They operate with user's - // attribute, which cannot be changed using user-mod, but only - // using command user-{add,remove}-certmap. Therefore it has set - // 'no_update' flag, but we need to show 'Add', 'Remove' buttons in - // WebUI. - if (that.metadata.flags && - array.indexOf(that.metadata.flags, 'no_update') > -1 && - !that.always_writable) { - writable = false; - } + if (that.check_writable_from_metadata) { + writable = that.load_writable_from_metadata(writable); } if (record && record.attributelevelrights) { |