mirror of
https://github.com/netzbegruenung/passbolt-salt
synced 2024-04-28 10:54:53 +02:00
Support new Passbolt API
* Some password objects are now JSON objects that need to be decoded.
This commit is contained in:
parent
20370e41dd
commit
967a38869e
|
@ -30,11 +30,24 @@ def generate_pillar(passbolt_obj, group_uuid):
|
||||||
for i in result:
|
for i in result:
|
||||||
resource = passbolt_obj.get("/secrets/resource/{}.json?api-version=v2".
|
resource = passbolt_obj.get("/secrets/resource/{}.json?api-version=v2".
|
||||||
format(i["id"]))
|
format(i["id"]))
|
||||||
salt['passbolt'][i["id"]] = passbolt_obj.decrypt(
|
data = passbolt_obj.decrypt(resource["body"]["data"])
|
||||||
resource["body"]["data"])
|
salt['passbolt'][i["id"]] = decode_json(data)
|
||||||
return salt
|
return salt
|
||||||
|
|
||||||
|
|
||||||
|
def decode_json(data):
|
||||||
|
"""
|
||||||
|
The passbolt API returns legacy strings or JSON objects.
|
||||||
|
Try to decode JSON, and if invalid return string.
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
try:
|
||||||
|
data = json.loads(data)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
return data
|
||||||
|
return data["password"]
|
||||||
|
|
||||||
|
|
||||||
def fetch_passbolt_passwords(group_uuid):
|
def fetch_passbolt_passwords(group_uuid):
|
||||||
"""
|
"""
|
||||||
Generate Passbolt API object and call API fetch function
|
Generate Passbolt API object and call API fetch function
|
||||||
|
|
Loading…
Reference in a new issue