Skip to main content

A simple yet flexible library (and command-line application) to access passwords.

Project description

Flexpass

A simple yet flexible library (and command-line application) to access passwords.

Installation

Flexpass package is available on PyPI.org:

pip install flexpass

Usage

Flexpass may be used as a library in your Python code:

from flexpass import get_password, set_password, delete_password, list_passwords
...

It may also be accessed directly as a command-line application. Flexpass PyPI package provides an executable that should be installed in your PATH:

flexpass --help

The application may also be invoked as a Python module:

python -m flexpass --help

Main features

This library provides read and write access to passwords, identified by a name, through the following functions:

def get_password(name: str) -> str|None:
    ...

def set_password(name: str, password: str, **options) -> None:
    ...

def delete_password(name: str) -> bool:
    ...

def list_passwords() -> list[PasswordInfo]:
    ...

Function get_password requests all registered backends (by decreasing priority order) until a password with the given name is found.

Function set_password sets the password in the read-write backend with the highest priority.

Function delete_password deletes the password in all read-write backends where the password was set. It returns True if the password was set in at least one backend.

Function list_passwords returns a list of the password names associated with information from the backends.

Access to passwords is also possible for a specific backend, by using this backend method. Examples:

backend = get_backend('pass')
backend.get_password('my/password')

Example of invokation of flexpass command-line application with list command (which is the default command when no argument is given). It retrives passwords using function list_passwords and format the results:

Result of --list command (example)

Backends

The following backends are included in Flexpass package:

Name(s) Priority Description
pass (or gpg) 80 Pass, the standard unix password manager, based on GPG. It has very few requirements and should be available on most workstations and servers.
wincred 50 Windows Credential Manager, the password manager integrated with Windows.

These backends are planned to be added later (ROADMAP):

Name(s) Priority Description
secretservice (or libsecret, secrettool, keyring, wallet) 60 Secret Service D-Bus API, a FreeDesktop.org standard usually accessed through libsecret and its frontends secret-tool, Gnome Keyring or KDE Wallet Manager.
secrets 30 Docker Compose secrets, made available in the containers at path /run/secrets/{name} or in /run/secrets/misc (or at local path secrets/{name}.txt or in secrets/misc.ini, usefull during development). Read-only.
dir 20 Directory in clear (by default /root/passwords).
env 10 Environment variables.

Custom backends may be registered in your Phon code using the register_backend_class function. Example:

from flexpass import register_backend_class
register_backend_class(MyCustomBackend, priority=70)

Pre-defined priorities may be modified by calling the register_backend_class with the new priority value. Example:

register_backend_class(WincredBackend, priority=5)

NOTE: priority 0 disables the backend.

License

This project is licensed under the terms of the MIT license.

Credits

Inspired by:

  • pass: the standard unix password manager based on GPG.
  • keyring.

Differences with keyring: - keyring is a lot more mature and has many more backends. - flexpass does not require to specify a username in addition to the password name. - flexpass provides a predictible and easily configurable order of precedence for the backends. - flexpass aims at including usual backends without requiring additional packages (in particular, the simple pass command is avaible). - flexpass easily gives access to the list of passwords.

Logo created by Pixel perfect - Flaticon.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

flexpass-0.1.0-py3-none-any.whl (17.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page