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:
|
||||
resource = passbolt_obj.get("/secrets/resource/{}.json?api-version=v2".
|
||||
format(i["id"]))
|
||||
salt['passbolt'][i["id"]] = passbolt_obj.decrypt(
|
||||
resource["body"]["data"])
|
||||
data = passbolt_obj.decrypt(resource["body"]["data"])
|
||||
salt['passbolt'][i["id"]] = decode_json(data)
|
||||
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):
|
||||
"""
|
||||
Generate Passbolt API object and call API fetch function
|
||||
|
|
Loading…
Reference in New Issue