Psono API interface for python
Project description
Psono python module
A Python client library and command-line interface for Psono password manager.
This module has been developed by http://www.cybersecure.com/ . We provide managed backups and data resilience.
Installation
pip install psonoapi
Or install from source:
git clone https://gitlab.com/cyber-secure-public/psono-python-module.git
cd psono-python-module
pip install -e .
Quick Start
1. Configuration / authentication
For the CLI
psono configure
This will prompt you for:
- Server URL
- API Key ID
- Private Key
- Secret Key
Using Environment Variables (Recommended) - CLI and module.
Instead of storing credentials in the config file, you can use environment variables:
server config:
export PSONO_API_SERVER_URL=https://psono.org.com/server
export PSONO_API_SERVER_PUBLIC_KEY=
export PSONO_API_SERVER_SIGNATURE=
credentials:
export PSONO_API_KEY_ID='your-key-id'
export PSONO_API_PRIVATE_KEY='your-private-key'
export PSONO_API_SECRET_KEY='your-secret-key'
Usage
CLI
# Check connection status
psono status
# List all secrets
psono secret list
# List secrets in a specific folder
psono secret list /websites
# Get a specific secret
psono secret get /websites/github
# Show password in plain text
psono secret get /websites/github --show-password
Module
import psonoapi
# This connects to the psono public server by default.
psonoserver=psonoapi.PsonoServerConfig(key_id='b3b5c964-50d2-40d7-a0f0-69ae43c498d3',
private_key='test'
secret_key='test')
psono = psonoapi.PsonoAPI(serverconfig=psonoserver)
# getting a secret (this requires full api)
mysecret = psono.get_path('sharename/foldername/secretname')
# getting a secret
mysecret = psono.get_secret(secret_id='b3b5c964-50d2-40d7-a0f0-69ae43c498d3')
# Getting a list of secrets that apply to a urlfilter:
mysecrets = psono.search_urlfilter('example.com')
# Updating (works as long as you have write permissions)
mysecret.title = 'I want a new title'
psono.update_secret(mysecret)
# You could also use write_secret instead
psono.write_secret(mysecret)
# Creating a new secret
newsecret = psono.generate_new_secret('website_password') # must be one of psonoapi.psono_type_list
newsecret : psonoapi.models.PsonoApplicationPassword # set the type to make life easy for yourself.
newsecret.path = 'existingfolder/newfolder/secretname'
newsecret.password = '1234'
newsecret.username = 'myusername'
newsecret.title = 'My special new secret'
psono.write_secret(newsecret)
CLI Usage
Basic Commands
# Check connection status
psono status
# List all secrets
psono secret list
# List secrets in a specific folder
psono secret list /websites
# Get a specific secret
psono secret get /websites/github
# Show password in plain text
psono secret get /websites/github --show-password
Creating Secrets
# Interactive mode
psono secret create /websites/github --interactive
# Create with JSON data
psono secret create /websites/github --data '{
"username": "myuser",
"password": "mypass",
"url": "https://github.com"
}'
# Create different types
psono secret create /notes/meeting --type note --interactive
psono secret create /cards/visa --type credit_card --data '{"number": "1234", "cvc": "123"}'
Updating and Deleting
# Update a secret
psono secret update /websites/github --data '{"password": "newpass"}'
# Delete a secret
psono secret delete /websites/github
Searching
# Search by title
psono secret search github
# Search in specific field
psono secret search example.com --field url
# Search by type
psono secret search "" --type website_password
Import/Export
# Export all secrets to JSON
psono export -o backup.json
# Export without passwords
psono export -o backup.json
# Export to CSV
psono export -o backup.csv --format csv
# Import from file
psono import -i backup.json
# Dry run import (preview changes)
psono import -i backup.json --dry-run
URL Matching
# Find credentials for a URL
psono find-by-url github.com
CLI Configuration
The CLI stores its configuration in ~/.psono/config.json. The configuration file contains:
{
"server_url": "https://psono.example.com/server",
"ssl_verify": true
}
API Usage
from psono import PsonoAPI
# Initialize client
api = PsonoAPI({
'key_id': 'your-key-id',
'private_key': 'your-private-key',
'secret_key': 'your-secret-key',
'server_url': 'https://psono.example.com/server'
})
# Create a password
from psono.models import PsonoWebsitePassword
password = api.generate_new_secret('website_password')
password.title = 'GitHub'
password.username = 'myuser'
password.password = 'securepass123'
password.url = 'https://github.com'
password.path = '/websites/github'
api.write_secret(password)
# Get a secret
secret = api.get_path('/websites/github')
print(f"Username: {secret.username}")
# Search by URL
matches = api.search_urlfilter('github.com')
for match in matches:
print(f"Found: {match.title} - {match.username}")
# List folder contents
folder = api.get_path('/websites')
for item in folder.items:
print(f"- {item.name}")
# Update existing secret
secret = api.get_path('/websites/github')
secret.password = 'newpassword123'
api.update_secret(secret)
# Delete a secret
api.delete_secret('/websites/old-site')
Secret Types
The following secret types are supported:
website_password- Website credentials with URLapplication_password- Application credentialsnote- Secure notescredit_card- Credit card informationbookmark- Bookmarksenvironment_variables- Environment variablestotp- TOTP/2FA codesssh_key- SSH keysmail_gpg_own_key- GPG keyselster_certificate- Elster certificates
Advanced Usage
Using Custom Fields
# Add custom fields to any secret
secret = api.get_path('/websites/example')
secret.custom_fields = [
{'name': 'API_KEY', 'type': 'text', 'value': 'abc123'},
{'name': 'Region', 'type': 'text', 'value': 'us-east-1'}
]
api.update_secret(secret)
# Access custom fields
print(secret.get_custom_field('API_KEY')) # 'abc123'
Working with Shares
# Get shared stores (A 'share' is a special type of datastore)
datastore = api.get_datastore()
for share in api.get_sharelist(datastore):
share_store = api.get_share(share)
print(f"Share: {share.name}")
Batch Operations
# Bulk create secrets
secrets = [
{
'type': 'website_password',
'path': f'/websites/{site}',
'username': f'user@{site}',
'password': 'temp123',
'url': f'https://{site}'
}
for site in ['example.com', 'test.com', 'demo.com']
]
for secret_data in secrets:
api.write_secret(secret_data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file psonoapi-0.2.3.tar.gz.
File metadata
- Download URL: psonoapi-0.2.3.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41b79327d564350521886cdd55ace85f04547f5e91aaabd55ae64f6d64e80d19
|
|
| MD5 |
60195f7039f62cdd1893d10109f5ae51
|
|
| BLAKE2b-256 |
871bccd5d0f994f151c6aa136bf332f826b31d1ea84f0c9dc4f865a15952c256
|
File details
Details for the file psonoapi-0.2.3-py3-none-any.whl.
File metadata
- Download URL: psonoapi-0.2.3-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
483ebcbb3cfa912263eea7a9e69b6138c6d62b4d05cfb42d597eeffa3aa90667
|
|
| MD5 |
ec32a36405003c933b9d6b844694ef0e
|
|
| BLAKE2b-256 |
37af20cb2bcef5efe1a97e2a85189ef0ffe14fd25b36a62aac9c42433a7c9f72
|