mirror of
https://github.com/netzbegruenung/passbolt-salt
synced 2024-05-03 04:44:52 +02:00
Fix module
This commit is contained in:
parent
5c99c5b046
commit
9396535bba
|
@ -1,28 +0,0 @@
|
||||||
"""
|
|
||||||
Provides functions to fetch passwords from passbolt api
|
|
||||||
"""
|
|
||||||
import passboltapi # pylint: disable=E0401
|
|
||||||
|
|
||||||
def get_password_list(passbolt_obj, group_uuid):
|
|
||||||
result = list()
|
|
||||||
for i in passbolt_obj.get(url="/resources.json?/resources.json?filter[is-shared-with-group]={}&api-version=v2".format(group_uuid))["body"]:
|
|
||||||
result.append({
|
|
||||||
"id": i["id"],
|
|
||||||
"name": i["name"],
|
|
||||||
"username": i["username"],
|
|
||||||
"uri": i["uri"]
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
|
|
||||||
def generate_pillar(passbolt_obj, group_uuid):
|
|
||||||
result = get_password_list(passbolt_obj, group_uuid)
|
|
||||||
salt = {'passbolt': {}}
|
|
||||||
for i in result:
|
|
||||||
resource = passbolt_obj.get("/secrets/resource/{}.json?api-version=v2".format(i["id"]))
|
|
||||||
salt['passbolt'][i["id"]] = passbolt_obj.decrypt(resource["body"]["data"])
|
|
||||||
return salt
|
|
||||||
|
|
||||||
def fetch_passbolt_passwords(group_uuid):
|
|
||||||
with passboltapi.PassboltAPI(config_path="/etc/salt/passbolt.ini") as passbolt:
|
|
||||||
salt = generate_pillar(passbolt_obj=passbolt, group_uuid)
|
|
||||||
return salt
|
|
45
src/salt_passbolt/__init__.py
Normal file
45
src/salt_passbolt/__init__.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
"""
|
||||||
|
Provides functions to fetch passwords from passbolt api
|
||||||
|
"""
|
||||||
|
import passboltapi # pylint: disable=E0401
|
||||||
|
|
||||||
|
|
||||||
|
def get_password_list(passbolt_obj, group_uuid):
|
||||||
|
"""
|
||||||
|
Get list of passwords for group UUID
|
||||||
|
"""
|
||||||
|
result = list()
|
||||||
|
url = ("/resources.json?/resources.json?filter[is-shared-with-group]" +
|
||||||
|
"={}&api-version=v2".format(group_uuid))
|
||||||
|
for i in passbolt_obj.get(url)["body"]: # pylint: disable=C0301
|
||||||
|
result.append({
|
||||||
|
"id": i["id"],
|
||||||
|
"name": i["name"],
|
||||||
|
"username": i["username"],
|
||||||
|
"uri": i["uri"]
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def generate_pillar(passbolt_obj, group_uuid):
|
||||||
|
"""
|
||||||
|
Generate dictionary that is added to the Pillar
|
||||||
|
"""
|
||||||
|
result = get_password_list(passbolt_obj, group_uuid)
|
||||||
|
salt = {'passbolt': {}}
|
||||||
|
for i in result:
|
||||||
|
resource = passbolt_obj.get("/secrets/resource/{}.json?api-version=v2".
|
||||||
|
format(i["id"]))
|
||||||
|
salt['passbolt'][i["id"]] = passbolt_obj.decrypt(
|
||||||
|
resource["body"]["data"])
|
||||||
|
return salt
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_passbolt_passwords(group_uuid):
|
||||||
|
"""
|
||||||
|
Generate Passbolt API object and call API fetch function
|
||||||
|
"""
|
||||||
|
path = "/etc/salt/passbolt.ini"
|
||||||
|
with passboltapi.PassboltAPI(config_path=path) as passbolt:
|
||||||
|
salt = generate_pillar(passbolt, group_uuid)
|
||||||
|
return salt
|
Loading…
Reference in a new issue