Skip to content

Commit

Permalink
[upgrade] Client enhanced with new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamdipt committed Nov 25, 2021
1 parent cc2161f commit 7bf6e20
Show file tree
Hide file tree
Showing 6 changed files with 27,476 additions and 26 deletions.
68 changes: 51 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Dependencies

- Python3
- Python >= 3.6
- GPG (also known as GnuPG) software

## Configuration
Expand All @@ -32,6 +32,39 @@ Or as a dictionary

## Usage


### Import GPG keys from Passbolt

The first step will be to import the private and public keys using gpg for encryption.

Note: Do not keep private and public files. Rather just import them using gpg command one time and delete those files.

#### Using Python
To import new keys using Python:

>>>import passboltapi
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True)

To delete old keys and import only the new ones.

>>>import passboltapi
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True, delete_old_keys=True)

#### Using GPG

Import new keys:

$gpg --import public.asc
$gpg --batch --import private.asc

Deleting existing keys:

$gpg --delete-secret-keys <fingerprint>
$gpg --delete-key <fingerprint>


## How to use PassboltAPI client

>>>import passboltapi
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini")
# Or pass the configuration settings as a dict
Expand All @@ -44,31 +77,32 @@ Or as a dictionary
# One can also use it as context manager
>>>with passboltapi.PassboltAPI(config_path="config.ini") as passbolt:

Check test.py for an example.

If new keys needs to be imported, then USER_PUBLIC_KEY_FILE and USER_PRIVATE_KEY_FILE settings
should be in the config ini having the path of the public and private keys file respectively.
To get all resources

To import new keys:
resources = {record.username: record for record in passbolt.list_resources(folder_id=folder_id)}

>>>import passboltapi
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True)
To create new resource (optional: folder)

To delete old keys and import only the new ones.
response = passbolt.create_resource(
name=name,
username=username,
password=password,
uri=uri, # optional
description=description, # optional
folder=passbolt_folder_id # optional
)

>>>import passboltapi
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True, delete_old_keys=True)
To move resource to folder

Recommended to do: Do not keep private and public files.
Rather just import them using gpg command one time and delete those files.
passbolt.move_resource_to_folder(resource_id, folder_id)

$gpg --import public.asc
$gpg --batch --import private.asc

For deleting gpg keys
### Sample test
Check test.py for an example.

$gpg --delete-secret-keys <fingerprint>
$gpg --delete-key <fingerprint>
If new keys needs to be imported, then USER_PUBLIC_KEY_FILE and USER_PRIVATE_KEY_FILE settings
should be in the config ini having the path of the public and private keys file respectively.


### Passbolt API
Expand Down
Loading

0 comments on commit 7bf6e20

Please sign in to comment.