Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
foreman_passwordstate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LiU IT - Infrastructure
foreman_passwordstate
Commits
6d667046
Verified
Commit
6d667046
authored
6 months ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Prepare for zeitwerk
parent
8f6c0a0d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/foreman_passwordstate/engine.rb
+3
-104
3 additions, 104 deletions
lib/foreman_passwordstate/engine.rb
lib/foreman_passwordstate/register.rb
+88
-0
88 additions, 0 deletions
lib/foreman_passwordstate/register.rb
with
91 additions
and
104 deletions
lib/foreman_passwordstate/engine.rb
+
3
−
104
View file @
6d667046
...
...
@@ -17,112 +17,11 @@ module ForemanPasswordstate
end
end
# rubocop:disable Metrics/BlockLength
initializer
'foreman_passwordstate.register_plugin'
,
before: :finisher_hook
do
|
_app
|
Foreman
::
Plugin
.
register
:foreman_passwordstate
do
requires_foreman
'>= 3.6'
apipie_documented_controllers
[
"
#{
ForemanPasswordstate
::
Engine
.
root
}
/app/controllers/api/v2/*.rb"
]
security_block
:foreman_passwordstate
do
permission
:view_passwordstate_servers
,
{
passwordstate_servers:
%i[index show]
},
resource_type:
'PasswordstateServer'
permission
:create_passwordstate_servers
,
{
passwordstate_servers:
%i[new create]
},
resource_type:
'PasswordstateServer'
permission
:edit_passwordstate_servers
,
{
passwordstate_servers:
%i[edit]
},
resource_type:
'PasswordstateServer'
permission
:delete_passwordstate_servers
,
{
passwordstate_servers:
%i[destroy]
},
resource_type:
'PasswordstateServer'
permission
:full_passwordstate_password_access
,
{
'api/v2/passwords'
:
%i[acquire release]
}
# permission :view_hosts,
# { hosts: %i[passwordstate_passwords_tab_selected] },
# resource_type: 'Host'
end
Foreman
::
AccessControl
.
permission
(
:view_hosts
).
actions
<<
'hosts/passwordstate_passwords_tab_selected'
role
'Passwordstate server viewer'
,
%i[view_passwordstate_servers]
role
'Passwordstate server manager'
,
%i[view_passwordstate_servers create_passwordstate_servers edit_passwordstate_servers delete_passwordstate_servers]
# Only meant for a puppetmaster user, to retrieve passwords into the catalog
role
'Password manager'
,
%i[full_passwordstate_password_access]
add_all_permissions_to_default_roles
# add menu entry
menu
:top_menu
,
:passwordstate_servers
,
url_hash:
{
controller: :passwordstate_servers
,
action: :index
},
caption:
N_
(
'Passwordstate Servers'
),
parent: :infrastructure_menu
register_facet
ForemanPasswordstate
::
PasswordstateHostFacet
,
:passwordstate_facet
do
configure_host
do
# extend_model ForemanPasswordstate::HostManagedExtensions # The #root_pass override fails if done here
add_tabs
passwords:
'foreman_passwordstate/passwords_tab_pane'
set_dependent_action
:destroy
end
configure_hostgroup
ForemanPasswordstate
::
PasswordstateHostgroupFacet
do
set_dependent_action
:destroy
end
end
register_info_provider
ForemanPasswordstate
::
HostInfoProvider
parameter_filter
Host
::
Managed
,
passwordstate_facet_attributes:
%i[passwordstate_server_id password_list_id]
parameter_filter
Hostgroup
,
passwordstate_facet_attributes:
%i[passwordstate_server_id password_list_id]
extend_page
(
'hosts/show'
)
do
|
ctx
|
ctx
.
add_pagelet
(
:main_tabs
,
name:
'Passwords'
,
partial:
'foreman_passwordstate/passwords_tab_pane_content'
,
onlyif:
proc
{
|
host
|
host
.
passwordstate_facet
}
)
end
%i[host hostgroup]
.
each
do
|
res
|
extend_page
(
"
#{
res
}
s/_form"
)
do
|
ctx
|
ctx
.
add_pagelet
(
:main_tab_fields
,
name:
'add_passwordstate_server_selection'
,
partial:
'foreman_passwordstate/host_server_selection'
,
resource_type:
res
)
end
end
logger
:sync
,
enabled:
true
initializer
'foreman_passwordstate.register_plugin'
,
before: :finisher_hook
do
|
app
|
app
.
reloader
.
to_prepare
do
require_relative
'register'
end
end
# rubocop:enable Metrics/BlockLength
# Precompile any JS or CSS files under app/assets/
# If requiring files from each other, list them explicitly here to avoid precompiling the same
# content twice.
assets_to_precompile
=
Dir
.
chdir
(
root
)
do
Dir
[
'app/assets/javascripts/**/*'
,
'app/assets/stylesheets/**/*'
].
map
do
|
f
|
f
.
split
(
File
::
SEPARATOR
,
4
).
last
.
gsub
(
/\.scss\Z/
,
''
)
end
end
initializer
'foreman_passwordstate.assets.precompile'
do
|
app
|
app
.
config
.
assets
.
precompile
+=
assets_to_precompile
end
initializer
'foreman_passwordstate.configure_assets'
,
group: :assets
do
SETTINGS
[
:foreman_passwordstate
]
=
{
assets:
{
precompile:
assets_to_precompile
}
}
end
config
.
to_prepare
do
Host
::
Managed
.
prepend
ForemanPasswordstate
::
HostManagedExtensions
...
...
This diff is collapsed.
Click to expand it.
lib/foreman_passwordstate/register.rb
0 → 100644
+
88
−
0
View file @
6d667046
# frozen_string_literal: true
Foreman
::
Plugin
.
register
:foreman_passwordstate
do
requires_foreman
'>= 3.12'
apipie_documented_controllers
[
"
#{
ForemanPasswordstate
::
Engine
.
root
}
/app/controllers/api/v2/*.rb"
]
security_block
:foreman_passwordstate
do
permission
:view_passwordstate_servers
,
{
passwordstate_servers:
%i[index show]
},
resource_type:
'PasswordstateServer'
permission
:create_passwordstate_servers
,
{
passwordstate_servers:
%i[new create]
},
resource_type:
'PasswordstateServer'
permission
:edit_passwordstate_servers
,
{
passwordstate_servers:
%i[edit]
},
resource_type:
'PasswordstateServer'
permission
:delete_passwordstate_servers
,
{
passwordstate_servers:
%i[destroy]
},
resource_type:
'PasswordstateServer'
permission
:full_passwordstate_password_access
,
{
'api/v2/passwords'
:
%i[acquire release]
}
# permission :view_hosts,
# { hosts: %i[passwordstate_passwords_tab_selected] },
# resource_type: 'Host'
end
Foreman
::
AccessControl
.
permission
(
:view_hosts
).
actions
<<
'hosts/passwordstate_passwords_tab_selected'
role
'Passwordstate server viewer'
,
%i[view_passwordstate_servers]
role
'Passwordstate server manager'
,
%i[view_passwordstate_servers create_passwordstate_servers edit_passwordstate_servers delete_passwordstate_servers]
# Only meant for a puppetmaster user, to retrieve passwords into the catalog
role
'Password manager'
,
%i[full_passwordstate_password_access]
add_all_permissions_to_default_roles
# add menu entry
menu
:top_menu
,
:passwordstate_servers
,
url_hash:
{
controller: :passwordstate_servers
,
action: :index
},
caption:
N_
(
'Passwordstate Servers'
),
parent: :infrastructure_menu
register_facet
ForemanPasswordstate
::
PasswordstateHostFacet
,
:passwordstate_facet
do
configure_host
do
# extend_model ForemanPasswordstate::HostManagedExtensions # The #root_pass override fails if done here
add_tabs
passwords:
'foreman_passwordstate/passwords_tab_pane'
set_dependent_action
:destroy
end
configure_hostgroup
ForemanPasswordstate
::
PasswordstateHostgroupFacet
do
set_dependent_action
:destroy
end
end
register_info_provider
ForemanPasswordstate
::
HostInfoProvider
parameter_filter
Host
::
Managed
,
passwordstate_facet_attributes:
%i[passwordstate_server_id password_list_id]
parameter_filter
Hostgroup
,
passwordstate_facet_attributes:
%i[passwordstate_server_id password_list_id]
extend_page
(
'hosts/show'
)
do
|
ctx
|
ctx
.
add_pagelet
(
:main_tabs
,
name:
'Passwords'
,
partial:
'foreman_passwordstate/passwords_tab_pane_content'
,
onlyif:
proc
{
|
host
|
host
.
passwordstate_facet
}
)
end
%i[host hostgroup]
.
each
do
|
res
|
extend_page
(
"
#{
res
}
s/_form"
)
do
|
ctx
|
ctx
.
add_pagelet
(
:main_tab_fields
,
name:
'add_passwordstate_server_selection'
,
partial:
'foreman_passwordstate/host_server_selection'
,
resource_type:
res
)
end
end
logger
:sync
,
enabled:
true
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment