Class: Katello::PermissionCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/katello/permission_creator.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(plugin) ⇒ PermissionCreator

Returns a new instance of PermissionCreator.



3
4
5
# File 'lib/katello/permission_creator.rb', line 3

def initialize(plugin)
  @plugin = plugin
end

Instance Method Details

#activation_keys_permissionsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/katello/permission_creator.rb', line 23

def activation_keys_permissions
  @plugin.permission :view_activation_keys,
                     {
                       'katello/activation_keys' => [:all, :index],
                       'katello/api/v2/activation_keys' => [:index, :show, :available_host_collections, :available_releases,
                                                            :product_content, :auto_complete_search],
                       'katello/api/v2/repository_sets' => [:index, :auto_complete_search],
                     },
                     :resource_type => 'Katello::ActivationKey',
                     :finder_scope => :readable
  @plugin.permission :create_activation_keys,
                     {
                       'katello/api/v2/activation_keys' => [:create, :copy],
                     },
                     :resource_type => 'Katello::ActivationKey'
  @plugin.permission :edit_activation_keys,
                     {
                       'katello/api/v2/activation_keys' => [:update, :content_override,
                                                            :add_host_collections, :remove_host_collections],
                     },
                     :resource_type => 'Katello::ActivationKey',
                     :finder_scope => :editable
  @plugin.permission :destroy_activation_keys,
                     {
                       'katello/api/v2/activation_keys' => [:destroy],
                     },
                     :resource_type => 'Katello::ActivationKey',
                     :finder_scope => :deletable
end

#alternate_content_source_permissionsObject



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/katello/permission_creator.rb', line 402

def alternate_content_source_permissions
  @plugin.permission :view_alternate_content_sources,
                     {
                       'katello/api/v2/alternate_content_sources' => [:index, :show, :auto_complete_search],
                     },
                     :resource_type => 'Katello::AlternateContentSource',
                     :finder_scope => :readable
  @plugin.permission :create_alternate_content_sources,
                     {
                       'katello/api/v2/alternate_content_sources' => [:create],
                     },
                     :resource_type => 'Katello::AlternateContentSource',
                     :finder_scope => :editable
  @plugin.permission :edit_alternate_content_sources,
                     {
                       'katello/api/v2/alternate_content_sources' => [:update, :refresh],
                       'katello/api/v2/alternate_content_sources_bulk_actions' => [:refresh_alternate_content_sources, :refresh_all_alternate_content_sources],
                     },
                     :resource_type => 'Katello::AlternateContentSource',
                     :finder_scope => :editable
  @plugin.permission :destroy_alternate_content_sources,
                     {
                       'katello/api/v2/alternate_content_sources' => [:destroy],
                       'katello/api/v2/alternate_content_sources_bulk_actions' => [:destroy_alternate_content_sources],
                     },
                     :resource_type => 'Katello::AlternateContentSource',
                     :finder_scope => :deletable
end

#capsule_content_permissionsObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/katello/permission_creator.rb', line 53

def capsule_content_permissions
  @plugin.permission :view_smart_proxies,
                     {
                       'katello/api/v2/capsules' => [:index, :show],
                     },
                     :resource_type => "SmartProxy"
  @plugin.permission :manage_capsule_content,
                     {
                       'katello/api/v2/capsule_content' => [:add_lifecycle_environment, :remove_lifecycle_environment,
                                                            :update_counts, :sync, :reclaim_space, :verify_checksum, :cancel_sync],
                       'katello/api/v2/capsules' => [:index, :show],
                     },
                     :resource_type => 'SmartProxy'

  @plugin.permission :view_capsule_content,
                     {
                       'katello/api/v2/capsule_content' => [:counts, :lifecycle_environments, :available_lifecycle_environments, :sync_status],
                       'smart_proxies' => [:pulp_storage, :pulp_status, :show_with_content],
                       'katello/api/v2/capsules' => [:index, :show],
                     },
                     :resource_type => "SmartProxy"
end

#content_credential_permissionsObject



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/katello/permission_creator.rb', line 158

def content_credential_permissions
  @plugin.permission :view_content_credentials,
                     {
                       'katello/api/v2/content_credentials' => [:index, :show, :content, :auto_complete_search],
                       'katello/api/v2/gpg_keys' => [:index, :show, :content, :auto_complete_search],
                     },
                     :resource_type => 'Katello::ContentCredential',
                     :finder_scope => :readable
  @plugin.permission :create_content_credentials,
                     {
                       'katello/api/v2/content_credentials' => [:create],
                       'katello/api/v2/gpg_keys' => [:create],
                     },
                     :resource_type => 'Katello::ContentCredential'
  @plugin.permission :edit_content_credentials,
                     {
                       'katello/api/v2/content_credentials' => [:update, :set_content],
                       'katello/api/v2/gpg_keys' => [:update, :set_content],
                     },
                     :resource_type => 'Katello::ContentCredential',
                     :finder_scope => :editable
  @plugin.permission :destroy_content_credentials,
                     {
                       'katello/api/v2/content_credentials' => [:destroy],
                       'katello/api/v2/gpg_keys' => [:destroy],
                     },
                     :resource_type => 'Katello::ContentCredential',
                     :finder_scope => :deletable
end

#content_view_permissionsObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/katello/permission_creator.rb', line 76

def content_view_permissions
  @plugin.permission :view_content_views,
             {
               'katello/api/v2/content_views' => [:index, :show, :auto_complete_search],
               'katello/api/v2/content_view_filters' => [:index, :show, :auto_complete_search],
               'katello/api/v2/content_view_filter_rules' => [:index, :show, :auto_complete_search],
               'katello/api/v2/content_view_histories' => [:index, :auto_complete_search],
               'katello/api/v2/content_view_repositories' => [:show_all],
               'katello/api/v2/content_view_versions' => [:index, :show, :auto_complete_search],
               'katello/api/v2/content_view_components' => [:index, :show, :show_all],
               'katello/api/v2/content_view_environments' => [:index],
               'katello/api/v2/debs' => [:index],
               'katello/api/v2/packages' => [:index],
               'katello/api/v2/package_groups' => [:index, :show, :auto_complete_search, :compare],
               'katello/api/v2/errata' => [:index, :show, :auto_complete_search, :compare],
               'katello/api/v2/module_streams' => [:index, :show, :auto_complete_search, :compare],
               'katello/api/v2/ansible_collections' => [:index, :show, :auto_complete_search, :compare],
               'katello/api/v2/repositories' => [:index, :show, :auto_complete_search, :compare],
               'katello/content_views' => [:auto_complete, :auto_complete_search],
               'katello/errata' => [:short_details, :auto_complete],
               'katello/packages' => [:details, :auto_complete],
               'katello/products' => [:auto_complete],
               'katello/repositories' => [:auto_complete_library],
               'katello/content_search' => [:index,
                                            :products,
                                            :repos,
                                            :packages,
                                            :errata,
                                            :packages_items,
                                            :errata_items,
                                            :module_streams,
                                            :ansible_collections,
                                            :view_packages,
                                            :repo_packages,
                                            :repo_errata,
                                            :repo_compare_errata,
                                            :repo_compare_packages,
                                            :view_compare_errata,
                                            :view_compare_packages,
                                            :views],
             },
             :resource_type => 'Katello::ContentView',
             :finder_scope => :readable
  @plugin.permission :create_content_views,
                     {
                       'katello/api/v2/content_views' => [:create, :copy],
                     },
                     :resource_type => 'Katello::ContentView'
  @plugin.permission :edit_content_views,
                     {
                       'katello/api/v2/content_views' => [:update, :remove_filters],
                       'katello/api/v2/content_view_versions' => [:update],
                       'katello/api/v2/content_view_filters' => [:create, :update, :destroy, :remove_filter_rules, :add_filter_rules],
                       'katello/api/v2/content_view_filter_rules' => [:create, :update, :destroy],
                       'katello/api/v2/content_view_components' => [:add_components, :remove_components, :update],
                     },
                     :resource_type => 'Katello::ContentView',
                     :finder_scope => :editable
  @plugin.permission :destroy_content_views,
                     {
                       'katello/api/v2/content_views' => [:destroy, :remove, :bulk_delete_versions],
                       'katello/api/v2/content_view_versions' => [:destroy],
                     },
                     :resource_type => 'Katello::ContentView',
                     :finder_scope => :deletable
  @plugin.permission :publish_content_views,
                     {
                       'katello/api/v2/content_views' => [:publish],
                       'katello/api/v2/content_view_versions' => [:incremental_update, :republish_repositories, :verify_checksum],
                       'katello/api/v2/content_imports' => [:version, :index],
                     },
                     :resource_type => 'Katello::ContentView',
                     :finder_scope => :publishable
  @plugin.permission :promote_or_remove_content_views,
                     {
                       'katello/api/v2/content_view_versions' => [:promote],
                       'katello/api/v2/content_views' => [:remove_from_environment, :remove, :republish_repositories, :verify_checksum],
                     },
                     :resource_type => 'Katello::ContentView',
                     :finder_scope => :promotable_or_removable
end

#defineObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/katello/permission_creator.rb', line 7

def define
  activation_keys_permissions
  capsule_content_permissions
  content_view_permissions
  content_credential_permissions
  host_collections_permissions
  lifecycle_environment_permissions
  organization_permissions
  product_permissions
  subscription_permissions
  sync_plan_permissions
  alternate_content_source_permissions
  flatpak_remote_permissions
  user_permissions
end

#flatpak_remote_permissionsObject



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/katello/permission_creator.rb', line 455

def flatpak_remote_permissions
  @plugin.permission :view_flatpak_remotes,
                     {
                       'katello/api/v2/flatpak_remotes' => [:index, :show, :auto_complete_search],
                       'katello/api/v2/flatpak_remote_repositories' => [:index, :show, :auto_complete_search],
                       'katello/api/v2/flatpak_remote_repository_manifests' => [:index, :show, :auto_complete_search],
                     },
                     :resource_type => 'Katello::FlatpakRemote',
                     :finder_scope => :readable
  @plugin.permission :create_flatpak_remotes,
                     {
                       'katello/api/v2/flatpak_remotes' => [:create],
                       'katello/api/v2/flatpak_remote_repositories' => [:create],
                       'katello/api/v2/flatpak_remote_repository_manifests' => [:create],
                     },
                     :resource_type => 'Katello::FlatpakRemote',
                     :finder_scope => :creatable
  @plugin.permission :edit_flatpak_remotes,
                     {
                       'katello/api/v2/flatpak_remotes' => [:update, :scan],
                       'katello/api/v2/flatpak_remote_repositories' => [:update],
                       'katello/api/v2/flatpak_remote_repository_manifests' => [:update],
                     },
                     :resource_type => 'Katello::FlatpakRemote',
                     :finder_scope => :editable
  @plugin.permission :destroy_flatpak_remotes,
                     {
                       'katello/api/v2/flatpak_remotes' => [:destroy],
                       'katello/api/v2/flatpak_remote_repositories' => [:destroy],
                       'katello/api/v2/flatpak_remote_repository_manifests' => [:destroy],
                     },
                     :resource_type => 'Katello::FlatpakRemote',
                     :finder_scope => :deletable
end

#host_collections_permissionsObject



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/katello/permission_creator.rb', line 188

def host_collections_permissions
  @plugin.permission :view_host_collections,
                     {
                       'katello/api/v2/host_collections' => [:index, :show, :auto_complete_search],
                     },
                     :resource_type => 'Katello::HostCollection',
                     :finder_scope => :readable
  @plugin.permission :create_host_collections,
                     {
                       'katello/api/v2/host_collections' => [:create, :copy],
                     },
                     :resource_type => 'Katello::HostCollection',
                     :finder_scope => :creatable
  @plugin.permission :edit_host_collections,
                     {
                       'katello/api/v2/host_collections' => [:update, :add_hosts, :remove_hosts],
                     },
                     :resource_type => 'Katello::HostCollection',
                     :finder_scope => :editable
  @plugin.permission :destroy_host_collections,
                     {
                       'katello/api/v2/host_collections' => [:destroy],
                     },
                     :resource_type => 'Katello::HostCollection',
                     :finder_scope => :deletable
end

#lifecycle_environment_permissionsObject



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/katello/permission_creator.rb', line 215

def lifecycle_environment_permissions
  @plugin.permission :view_lifecycle_environments,
                     {
                       'katello/api/v2/environments' => [:index, :show, :paths, :repositories, :auto_complete_search],
                       'katello/api/rhsm/candlepin_proxies' => [:rhsm_index],
                       'katello/api/v2/content_view_environments' => [:index],
                     },
                     :resource_type => 'Katello::KTEnvironment',
                     :finder_scope => :readable
  @plugin.permission :create_lifecycle_environments,
                     {
                       'katello/api/v2/environments' => [:create],
                     },
                     :resource_type => 'Katello::KTEnvironment',
                     :finder_scope => :creatable
  @plugin.permission :edit_lifecycle_environments,
                     {
                       'katello/api/v2/environments' => [:update],
                     },
                     :resource_type => 'Katello::KTEnvironment',
                     :finder_scope => :editable
  @plugin.permission :destroy_lifecycle_environments,
                     {
                       'katello/api/v2/environments' => [:destroy],
                     },
                     :resource_type => 'Katello::KTEnvironment',
                     :finder_scope => :deletable
  @plugin.permission :promote_or_remove_content_views_to_environments,
                     {},
                     :resource_type => 'Katello::KTEnvironment',
                     :finder_scope => :promotable
end

#organization_permissionsObject



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/katello/permission_creator.rb', line 439

def organization_permissions
  @plugin.permission :import_content,
                     {
                       'katello/api/v2/content_imports' => [:library, :version, :index, :repository],
                     },
                     :resource_type => 'Organization'

  @plugin.permission :export_content,
                     {
                       'katello/api/v2/content_view_versions' => [:export, :repository],
                       'katello/api/v2/content_exports' => [:library, :version, :index, :repository],
                       'katello/api/v2/content_export_incrementals' => [:library, :version, :repository],
                     },
                     :resource_type => 'Organization'
end

#product_permissionsObject



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/katello/permission_creator.rb', line 248

def product_permissions
  @plugin.permission :view_products,
                     {
                       'katello/products' => [:auto_complete, :auto_complete_search],
                       'katello/api/v2/products' => [:index, :show, :auto_complete_search, :auto_complete_name],
                       'katello/api/v2/repositories' => [:index, :show, :repository_types, :content_types, :auto_complete_search, :cancel],
                       'katello/api/v2/packages' => [:index, :thindex, :show, :auto_complete_search, :auto_complete_name, :auto_complete_arch, :compare],
                       'katello/api/v2/srpms' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/debs' => [:index, :thindex, :show, :auto_complete_search, :auto_complete_name, :auto_complete_arch, :compare],
                       'katello/api/v2/package_groups' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/docker_manifests' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/docker_manifest_lists' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/docker_tags' => [:index,
                                                        :show,
                                                        :auto_complete_search,
                                                        :auto_complete_name,
                                                        :compare,
                                                        :repositories],
                       'katello/api/v2/file_units' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/errata' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/module_streams' => [:index, :show, :auto_complete_search, :compare, :auto_complete_name],
                       'katello/api/v2/ansible_collections' => [:index, :show, :auto_complete_search, :compare],
                       'katello/api/v2/generic_content_units' => [:index, :show, :auto_complete_search, :compare],
                       'katello/errata' => [:short_details, :auto_complete],
                       'katello/packages' => [:details, :auto_complete],
                       'katello/files' => [:auto_complete],
                       'katello/generic' => [:auto_complete],
                       'katello/repositories' => [:auto_complete_library, :repository_types],
                       'katello/content_search' => [:index,
                                                    :products,
                                                    :repos,
                                                    :packages,
                                                    :errata,
                                                    :packages_items,
                                                    :errata_items,
                                                    :module_streams,
                                                    :ansible_collections,
                                                    :repo_packages,
                                                    :repo_errata,
                                                    :repo_compare_errata,
                                                    :repo_compare_packages],
                       'katello/api/v2/repository_sets' => [:index, :show, :available_repositories, :auto_complete_search],
                       'katello/api/v2/host_packages' => [:installed_packages],
                       'katello/api/v2/host_debs' => [:installed_debs],
                     },
                     :resource_type => 'Katello::Product',
                     :finder_scope => :readable
  @plugin.permission :create_products,
                     {
                       'katello/api/v2/products' => [:create],
                     },
                     :resource_type => 'Katello::Product',
                     :finder_scope => :editable
  @plugin.permission :edit_products,
                     {
                       'katello/api/v2/products' => [:update],
                       'katello/api/v2/repositories' => [:create, :update, :remove_content, :import_uploads, :upload_content, :republish, :verify_checksum, :reclaim_space],
                       'katello/api/v2/products_bulk_actions' => [:update_sync_plans, :update_http_proxy, :verify_checksum_products],
                       'katello/api/v2/content_uploads' => [:create, :update, :destroy],
                       'katello/api/v2/organizations' => [:repo_discover, :cancel_repo_discover],
                       'katello/api/v2/repository_sets' => [:enable, :disable],
                       'katello/api/v2/flatpak_remote_repositories' => [:mirror],
                     },
                     :resource_type => 'Katello::Product',
                     :finder_scope => :editable
  @plugin.permission :destroy_products,
                     {
                       'katello/api/v2/products' => [:destroy],
                       'katello/api/v2/repositories' => [:destroy],
                       'katello/api/v2/products_bulk_actions' => [:destroy_products],
                       'katello/api/v2/repositories_bulk_actions' => [:destroy_repositories],
                     },
                     :resource_type => 'Katello::Product',
                     :finder_scope => :deletable
  @plugin.permission :sync_products,
                     {
                       'katello/api/v2/products' => [:sync],
                       'katello/api/v2/repositories' => [:sync],
                       'katello/api/v2/products_bulk_actions' => [:sync_products],
                       'katello/api/v2/repositories_bulk_actions' => [:sync_repositories, :reclaim_space_from_repositories],
                       'katello/api/v2/sync' => [:index],
                       'katello/sync_management' => [:index, :sync_status, :product_status, :sync, :destroy],
                     },
                     :resource_type => 'Katello::Product',
                     :finder_scope => :syncable
end

#subscription_permissionsObject



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/katello/permission_creator.rb', line 335

def subscription_permissions
  @plugin.permission :view_subscriptions,
                     {
                       'katello/api/v2/subscriptions' => [:index, :show, :available, :manifest_history, :auto_complete_search],
                     },
                     :resource_type => 'Katello::Subscription'
  @plugin.permission :attach_subscriptions,
                     {
                       'katello/api/v2/subscriptions' => [:create],
                     },
                     :resource_type => 'Katello::Subscription'
  @plugin.permission :unattach_subscriptions,
                     {
                       'katello/api/v2/subscriptions' => [:destroy],
                     },
                     :resource_type => 'Katello::Subscription'
  @plugin.permission :import_manifest,
                     {
                       'katello/api/v2/subscriptions' => [:upload, :refresh_manifest],
                     },
                     :resource_type => 'Katello::Subscription'
  @plugin.permission :delete_manifest,
                     {
                       'katello/api/v2/subscriptions' => [:delete_manifest],
                     },
                     :resource_type => 'Katello::Subscription'
  @plugin.permission :manage_subscription_allocations,
                     {
                       'katello/api/v2/upstream_subscriptions' => [:index, :create, :destroy, :update, :ping, :enable_simple_content_access, :disable_simple_content_access, :simple_content_access_eligible, :simple_content_access_status],
                       'katello/api/v2/simple_content_access' => [:enable, :disable, :eligible, :status],
                     },
                     :resource_type => 'Katello::Subscription'
end

#sync_plan_permissionsObject



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/katello/permission_creator.rb', line 369

def sync_plan_permissions
  @plugin.permission :view_sync_plans,
                     {
                       'katello/api/v2/sync_plans' => [:index, :show, :add_products, :remove_products, :available_products, :auto_complete_search],
                     },
                     :resource_type => 'Katello::SyncPlan',
                     :finder_scope => :readable
  @plugin.permission :create_sync_plans,
                     {
                       'katello/api/v2/sync_plans' => [:create],
                     },
                     :resource_type => 'Katello::SyncPlan',
                     :finder_scope => :editable
  @plugin.permission :edit_sync_plans,
                     {
                       'katello/api/v2/sync_plans' => [:update],
                     },
                     :resource_type => 'Katello::SyncPlan',
                     :finder_scope => :editable
  @plugin.permission :destroy_sync_plans,
                     {
                       'katello/api/v2/sync_plans' => [:destroy],
                     },
                     :resource_type => 'Katello::SyncPlan',
                     :finder_scope => :deletable
  @plugin.permission :sync_sync_plans,
                     {
                       'katello/api/v2/sync_plans' => [:sync],
                     },
                     :resource_type => 'Katello::SyncPlan',
                     :finder_scope => :syncable
end

#user_permissionsObject



431
432
433
434
435
436
437
# File 'lib/katello/permission_creator.rb', line 431

def user_permissions
  @plugin.permission :my_organizations,
                     {
                       'katello/api/rhsm/candlepin_proxies' => [:list_owners],
                     },
                     :public => true
end