semvec/pypi-packages huggingface dataset:
zoho_vault_client 0.1.1
Zoho Vault client, get secrets and decrypt them
Requires Python: >=3.11,<4.0

# zoho-vault-client

[![Pull Request Checks](https://github.com/danbailo/zoho-vault-client/actions/workflows/pull-request-checks.yaml/badge.svg)](https://github.com/danbailo/zoho-vault-client/actions/workflows/pull-request-checks.yaml)

Simple OAuth 2 client to get secrets and decrypt value from ZohoVault.


### Motivation

Using the API provided by ZohoVault, you will only get the encrypted data from a specific secret that you want to get.

- https://www.zoho.com/vault/api/#step-5---decrypting-secret-data:
- https://help.zoho.com/portal/en/community/topic/how-to-decrypt-secretdata


This project implement a client that do it for you.

## Using through CLI

To run this application through cli, you need to export this following enviroment variables:

- CLIENT_ID
- CLIENT_SECRET
- TOKEN_URL
- ORG_KEY
- REFRESH_TOKEN

Then, just run any of these commands from root project.

`python -m zoho_vault_client get-secret -n SECRET_NAME`
> decrypted value -> {'username': 'foo', 'password': 'bar'}

`python -m zoho_vault_client get-secret -id SECRET_ID`
> decrypted value -> {'file_name': 'foo', 'data': {'test': 'foo', 'lorem': 'ipsum'}}

You can only decrypt a encrypted secret direct from cli.

`python -m zoho_vault_client decrypt -e "QwMd0dcD0WUnY8mMABKcd6B0Fw=="`
> decrypted value -> test

`python -m zoho_vault_client decrypt -e "U2FsdGVkX1+CNkcuXbv6jxv6RWHhB3ZWgSYE2aP4pN4xw8VKHZnjL/Sny8/ZDsKTvepfagCFHAi4I9f3Kfa2RNHWkMiOolHlBqnbx2dhLkzHfderkETJt2c6tlQ2fbRQ+0xlaj9He/1LiGx76arv+ctnN387f7PrwAFIVh1Rr0U=" --is-file`
> decrypted value -> data:application/json;base64,ewogICAgInRlc3QiOiAiZm9vIiwKICAgICJhbm90aGVyX3NlY3JldCI6ICJWQUxVRSIKfQo=

## How to use

```
from zoho_vault_client.zoho_vault.client import ZohoVaultClient
from zoho_vault_client.zoho_vault.decrypter import ZohoVaultDecrypter
from zoho_vault_client.zoho_vault.session import ZohoVaultSession

# Instance a ZohoVault Session
zoho_vault_session = ZohoVaultSession(
    client_id='YOUR-CLIENT-ID',
    client_secret='YOUR-CLIENT-SECRET',
    token_url='YOUR-TOKEN-URL',
    org_key='YOUR-ORG-KEY',
    refresh_token='YOUR-REFRESH-TOKEN',
)

# Instance a ZohoVault Decrypter
zoho_vault_decrypter = ZohoVaultDecrypter(
    password='YOUR-ORG-KEY',  # same as `org_key`
)

# Instance a ZohoVault Client
zoho_vault_client = ZohoVaultClient(
    zoho_vault_session,
    zoho_vault_decrypter,
)

print(zoho_vault_client.get_secret(secret_name='foo'))
print(zoho_vault_client.get_secret(secret_id='123'))
```