Skip to content

Commit 0c30928

Browse files
committed
Bypass feature validation for dynamic tenant features
We expect a one to one feature assignment with existing product features. This doesn't work with dynamic tenant features. This dynamic tenant feature was only ever implemented for tenant quotas. Related to: ManageIQ#5123 ManageIQ#5129 ManageIQ#5142 Fixes: ManageIQ#9512
1 parent 90252f1 commit 0c30928

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

app/controllers/ops_controller/ops_rbac.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def role_allows?(**options)
1717
end
1818

1919
options[:feature] = MiqProductFeature.tenant_identifier(options[:feature], id)
20+
# dynamic tenant feature identifiers need to bypass feature validation
21+
options[:skip_feature_validation] = true
2022
end
2123

2224
super(**options)

app/helpers/application_helper.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ def role_allows?(**options)
104104
return false
105105
end
106106

107+
# ops_rbac role_allows's dynamic tenant features are supported in rbac but not
108+
# with direct lookup in validate_features so we skip it.
109+
validate_features(features) unless !!options.delete(:skip_feature_validation)
110+
111+
Rbac.role_allows?(:user => User.current_user, **options) rescue false
112+
end
113+
module_function :role_allows?
114+
public :role_allows?
115+
116+
def validate_features(features)
107117
# Detect if queried features are missing from the database and possibly invalid
108118
if !Rails.env.production? && features.detect { |feature| !MiqProductFeature.feature_exists?(feature) }
109119
message = "#{__method__} no feature was found with identifier: #{features.inspect}. Correct the identifier or add it to miq_product_features.yml."
@@ -114,12 +124,8 @@ def role_allows?(**options)
114124
raise("#{message} Note: detected features: #{identifiers.inspect}")
115125
end
116126
end
117-
118-
Rbac.role_allows?(:user => User.current_user, **options) rescue false
119127
end
120-
121-
module_function :role_allows?
122-
public :role_allows?
128+
module_function :validate_features
123129

124130
# NB: This differs from controller_for_model; until they're unified,
125131
# make sure you have the right one.

0 commit comments

Comments
 (0)