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
fd05d34b
Verified
Commit
fd05d34b
authored
6 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Separate host password lookup to allow reuse
parent
34c88e7a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models/concerns/foreman_passwordstate/host_managed_extensions.rb
+14
-6
14 additions, 6 deletions
...concerns/foreman_passwordstate/host_managed_extensions.rb
with
14 additions
and
6 deletions
app/models/concerns/foreman_passwordstate/host_managed_extensions.rb
+
14
−
6
View file @
fd05d34b
...
@@ -17,7 +17,7 @@ module ForemanPasswordstate
...
@@ -17,7 +17,7 @@ module ForemanPasswordstate
delegate
:passwordstate_server
,
to: :passwordstate_facet
delegate
:passwordstate_server
,
to: :passwordstate_facet
delegate
:password_list
,
to: :passwordstate_facet
,
prefix: :passwordstate
delegate
:password_list
,
to: :passwordstate_facet
,
prefix: :passwordstate
def
host_pass
(
username
,
create:
true
,
**
params
)
def
password_entry
(
username
,
create:
true
,
**
params
)
return
nil
unless
passwordstate_facet
return
nil
unless
passwordstate_facet
list
=
passwordstate_password_list
list
=
passwordstate_password_list
...
@@ -34,16 +34,18 @@ module ForemanPasswordstate
...
@@ -34,16 +34,18 @@ module ForemanPasswordstate
end
end
end
end
def
roo
t_pass
def
hos
t_pass
(
username
,
password_hash:
'SHA256'
,
create:
true
,
**
params
)
return
super
unless
passwordstate_facet
return
nil
unless
passwordstate_facet
# As template renders read the root password multiple times,
# As template renders read the root password multiple times,
# add a short cache just to not thoroughly hammer the passwordstate server
# add a short cache just to not thoroughly hammer the passwordstate server
PasswordstateCache
.
instance
.
fetch
(
"
#{
cache_key
}
/
root_pass
"
,
expires_in:
1
.
minute
)
do
PasswordstateCache
.
instance
.
fetch
(
"
#{
cache_key
}
/
pass-
#{
username
}
"
,
expires_in:
1
.
minute
)
do
pw
=
host_pass
(
'root'
)
pw
=
password_entry
(
username
,
create:
create
,
**
params
)
alg
=
operatingsystem
&
.
password_hash
||
'SHA256'
alg
=
password_hash
||
'SHA256'
if
alg
==
'Base64'
if
alg
==
'Base64'
pw
=
PasswordCrypt
.
passw_crypt
(
pw
.
password
,
alg
)
pw
=
PasswordCrypt
.
passw_crypt
(
pw
.
password
,
alg
)
elsif
alg
==
'None'
pw
=
pw
.
password
else
else
seed
=
"
#{
uuid
||
id
}
/
#{
pw
.
title
}
-
#{
pw
.
password_id
}
"
seed
=
"
#{
uuid
||
id
}
/
#{
pw
.
title
}
-
#{
pw
.
password_id
}
"
rand
=
Random
.
new
(
seed
.
hash
)
rand
=
Random
.
new
(
seed
.
hash
)
...
@@ -53,5 +55,11 @@ module ForemanPasswordstate
...
@@ -53,5 +55,11 @@ module ForemanPasswordstate
pw
pw
end
end
end
end
def
root_pass
return
super
unless
passwordstate_facet
host_pass
(
'root'
,
password_hash:
operatingsystem
&
.
password_hash
)
end
end
end
end
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