13
1
Fork 0
mirror of https://github.com/netzbegruenung/passbolt-salt synced 2024-05-03 04:44:52 +02:00

Support local file for passbolt replacement

* During development access to the Passbolt server may
  not always be possible. Allow a local file as fallback.
This commit is contained in:
Sven Seeberg 2021-05-29 16:30:14 +02:00
parent 967a38869e
commit f1750202be
Signed by: sven.seeberg
GPG key ID: 29559DD5A83806B5
2 changed files with 30 additions and 3 deletions

View file

@ -1,6 +1,11 @@
# About # About
This Python module retrieves passwords for Passbolt groups to make them available in Saltstack Pillar. This Python module retrieves passwords for Passbolt groups to make them available in Saltstack Pillar.
For development, a local file named `[UUID].txt` can be placed in the pillar directory. It needs to contain lines with the format
```
3ec2a739-8e51-4c67-89fb-4bbfe9147e17:MY_SECRET
```
# License # License
MIT MIT
@ -43,8 +48,18 @@ MIT
``` ```
#!py #!py
def run(): def run():
from salt_passbolt import fetch_passbolt_passwords passbolt_group = "27b9abd4-af9b-4c9e-9af1-cf8cb963680c"
return fetch_passbolt_passwords("27b9abd4-af9b-4c9e-9af1-cf8cb963680c") from os import path
file_path = path.join(path.dirname(path.realpath(__file__)), passbolt_group + ".txt")
if path.isfile(file_path):
with open(file_path) as f:
data = {"passbolt": {}}
for line in f.readlines():
data["passbolt"][line.split(':')[0]] = line.split(':')[1]
return data
else:
from salt_passbolt import fetch_passbolt_passwords
return fetch_passbolt_passwords(passbolt_group)
``` ```
9. In state, reference secrets with their UUID. See the `example/salt/important_secrets/files/secret.conf`. Hint: you can find the secret UUID in the URL of your browser by clicking on the checkbox of a secret. 9. In state, reference secrets with their UUID. See the `example/salt/important_secrets/files/secret.conf`. Hint: you can find the secret UUID in the URL of your browser by clicking on the checkbox of a secret.

View file

@ -1,3 +1,15 @@
#!py #!py
fetch_passbolt_passwords("27b9abd4-af9b-4c9e-9af1-cf8cb963680c") def run():
passbolt_group = "27b9abd4-af9b-4c9e-9af1-cf8cb963680c"
from os import path
file_path = path.join(path.dirname(path.realpath(__file__)), passbolt_group + ".txt")
if path.isfile(file_path):
with open(file_path) as f:
data = {"passbolt": {}}
for line in f.readlines():
data["passbolt"][line.split(':')[0]] = line.split(':')[1]
return data
else:
from salt_passbolt import fetch_passbolt_passwords
return fetch_passbolt_passwords(passbolt_group)