Skip to main content

keyringrs

A Python binding for keyring-rs.

While keyring is a great tool, it doesn't fully meet our general requirements due to the following reasons:

  • Native Linux Keyutils Support: We need seamless integration with keyutils on Linux.
  • Proper Memory Management on macOS: We perform numerous key queries, and keyring has known memory management issues on macOS (see issue jaraco/keyring #670).
  • Headless Linux without dbus-x11: In CI, we test the secret-service on a headless linux (GitHub CI), the workaround starts the Gnome keyring unlocked with a known password from kering-rs CI works without dbus-x11 required.

The keyringrs is not plan as the alternative of keyring. For CLI tool and more generic use cases I recommend to go to keyring.

Aside from our specific requirements with macOS and Linux keyutils, this library can serve as a backup solution if there are unresolved issues. While it doesn't guarantee a fix for the problems encountered, it can be a helpful tool to distinguish whether the issue stems from the library itself or from system configuration.

This library aims to maintain API compatibility with keyring-rs as closely as possible. It therefore provide built-in support following platform-specific credential stores inherited from keyring-rs:

  • Linux: The DBus-based Secret Service, the kernel keyutils, and a combo of the two (see below for example on how to control to use only keyutils).
  • FreeBSD, OpenBSD: The DBus-based Secret Service.
  • macOS, iOS: The local keychain.
  • Windows: The Windows Credential Manager.

Installation

To install the package, simply run:

pip install keyringrs

Usage

Here's a quick example of how to use keyringrs. For all platforms service-name and key-name are required fields to create a key entry to distinguish from other keys. The target field is optional and depends on target platforms, please check docs from keyring-rs for particular cases:

from keyringrs import Entry

# Create an entry for the given service and username
# Or `entry = Entry("my-service-name", "my-key-name", target="my-target-name")`
entry = Entry("my-service-name", "my-key-name")

# Set a password
entry.set_password("0Xl$$K6o2bBwDe")

# Retrieve the password
password = entry.get_password()
print(f"My password is '{password}'")

# Delete the credential
entry.delete_credential()

In linux, by default it assume it used in a desktop distro with libdbus installed. For the fallback support to use only keyutils, the key stored will disappear after reboot.

from keyringrs import Entry, CredentialType

# Create an entry use only keyutils in linux
entry = Entry("my-service-name", "my-key-name", credential_type=CredentialType.KeyUtils)

This interface follows the same logic as keyring-rs to ensure consistency and ease of use.

Checking keys on different platforms

tree layout

The repo organized using mixed rust/python layout.

.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── keyringrs
│   └── __init__.py
├── pyproject.toml
├── src
│   └── lib.rs
├── tests
│   └── test_base.py
└── uv.lock

Ack

There was an effort five years ago with pyrust-keyring. However, over the years, keyring-rs has gained more features, become more robust, and slightly diverged from the original keyring library. It would be beneficial to have a proper wrapper for it.

Additionally, pyo3 has significantly improved, making it much easier to create wrappers and distribute the library on PyPI.

There is also a python wrapper python-linux-keyutils for linux-keyutils crate, which may provide more keyutils related APIs and error messages.

License

Contributions

Unless you explicitly state otherwise, any contribution that you intentionally submit for inclusion in the Work, as defined in the Apache License, Version 2.0, shall be dual-licensed as described above, without additional terms or conditions.

Download files

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

Source Distribution

keyringrs-0.4.1.tar.gz (37.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

keyringrs-0.4.1-cp39-abi3-win_amd64.whl (155.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

keyringrs-0.4.1-cp39-abi3-win32.whl (146.7 kB view details)

Uploaded CPython 3.9+Windows x86

keyringrs-0.4.1-cp39-abi3-musllinux_1_2_x86_64.whl (979.9 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

keyringrs-0.4.1-cp39-abi3-musllinux_1_2_i686.whl (1.0 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

keyringrs-0.4.1-cp39-abi3-musllinux_1_2_armv7l.whl (1.0 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

keyringrs-0.4.1-cp39-abi3-musllinux_1_2_aarch64.whl (938.1 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

keyringrs-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (764.4 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

keyringrs-0.4.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (800.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

keyringrs-0.4.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (933.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

keyringrs-0.4.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (736.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

keyringrs-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (747.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

keyringrs-0.4.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (829.0 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

keyringrs-0.4.1-cp39-abi3-macosx_11_0_arm64.whl (259.8 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

keyringrs-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl (258.8 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file keyringrs-0.4.1.tar.gz.

File metadata

  • Download URL: keyringrs-0.4.1.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for keyringrs-0.4.1.tar.gz
Algorithm Hash digest
SHA256 6684e3d0ac70d2c3f0397b1295ae4b1f3bfe2fe889d0d61a0f980122ee0b534d
MD5 d577a5c5b2a5f2df7e7857740f284044
BLAKE2b-256 0b19168f782a55f541ee236840b3ee95c82e7ec7a5fdeea3656ab8600ac66bb8

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: keyringrs-0.4.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 155.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 986c823c4a3cbb68e50c1292a2d9820eaff0592c8b285059fac43fe331154508
MD5 b41ad67d9d6f1f89b9e6c15372ee2ff6
BLAKE2b-256 17700a9296ae475923970cfe46fba5324a0c3a5f0dcb639df05d8ad30f43756d

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-win32.whl.

File metadata

  • Download URL: keyringrs-0.4.1-cp39-abi3-win32.whl
  • Upload date:
  • Size: 146.7 kB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 8aa48dd24adb9affad3a8b92b1e679a6d9842521dfd80e4c650048dfb869af8e
MD5 63a2133d70532e4a3375e4040e1bfd0a
BLAKE2b-256 acbb0bfd7f6433dcca6bce126443eff6f5d827aa9de8ac32ef67b55b1af90bac

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d45d8a986f406805a5b9248563b9bf9ee32cbb7ef0d2aea412382b5c22bf7b2a
MD5 c03e92015be45692aee135ee88a1cff9
BLAKE2b-256 7c173b761410ea15f84f99161f9aac0650298ad64e28364e4f4b7d3aa7f40ffd

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7d02f042ade096e110cb08d76a7802c241eb10fa3542cdfa2a3253d3081c1d4d
MD5 2b97b4a7443ca7967fe8fc2f1b3a47e3
BLAKE2b-256 af565a326b6ee923b69688aa0f7049d1e848de776ece6da984fe6f88da8448d0

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 cf33f9b5b3c0c75f2e0c648b495159d0ca7d0505c3822c71b2b01763d8ab74c0
MD5 fe18eaf32a092a66a6418a03cc30c03e
BLAKE2b-256 3cf7429944494a28cafe91949cc5b0bff123266b0717c70f3e8545df0e2b2927

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 83e367c5a673508f697105b4f4e9808ec9f6d3e358c46e8704e8af4f30ce1a9f
MD5 0bcac99e41cfd8d91bd19e8cea08514d
BLAKE2b-256 f752cb30fefae83a746f1892a4f0db00fa29aebbf57e7bb32e04e30213657d95

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b04b7097bc655c8eaf6ed3f7ef95b2d246325c521016ae8963782be42ac29a6f
MD5 405751b3f760ad48adf6bef4d12c75dc
BLAKE2b-256 45232c400e06434ece2a4cdc71f72b468d3a3065380a769a250caf9106b348d5

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 0a1499f1b1bbecd37a8cbe190b8c947807b83ccfaec1a46b0f2da0305e2c64ff
MD5 b0f762bd214506d8a06b7e089bf9dd78
BLAKE2b-256 9687d815b40e5daf641c7cc1cf77ccc6bee1d886d66f36cffe20b31da86aacf1

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 9a0b01b4eeb6f1a572c13a94983263999af92a0d63337e02c8d9a3c1ed5d9a78
MD5 deebb9c54f5d61e47dcd21f06d898e49
BLAKE2b-256 856706b28ccc03b1281f572398755a69fe414ff1abaa2771ff2ac58c4aa055c7

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a63d6b6f613b8ab3d0aa398912d6654c825512e0189707b4274479844c59d3ab
MD5 04ce38841613cca1e1baf06f8d8f9096
BLAKE2b-256 da38eba7a0f9752cb46b142f613ebb424de36db64b4954712d5ef2cbe2fb9287

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4aa20de874fa743f18522a013cc976498bb2b0c9039d80e4d7e65238c4d950a8
MD5 669af27b225f90290ce82a9974ef7ebf
BLAKE2b-256 8af4481c830210be0322ecf366738ad8ece05a90bcb2a4458b0e79650b8a49ee

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 28a51808722ae90ee2abbbb1e503a80f3ef448fb82fe051444611fbc288817cc
MD5 ca5c98b9c31262e514147a258f633bbd
BLAKE2b-256 3571e38f1419e68cfcf082001d56952e0d2c8474537c7a6b321b9f0165369140

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f71e2941f8c49d5b06e1b4601c858248ad2e78ec1f986828c70a435e5b4ef09f
MD5 f823af65c6327ef33f52038252a32829
BLAKE2b-256 5e37dfe7d320943882c81e491b65fbeff5d61cdbd0ccc6f140e09e5a0e38b534

See more details on using hashes here.

File details

Details for the file keyringrs-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for keyringrs-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8353c2c0f1116733c6f54f83f590e1028eda0d3ebf3d9f9f43bea46611f168d3
MD5 2bcc73e613135eb5142caabe25d8f147
BLAKE2b-256 9670b2a124796acc418e67fc981cb2fde77f394ebfa5862333300a7f80a075c0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.1 This release

15 files

0.4.0

15 files

0.3.1

15 files

0.1.0

15 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page