Skip to content

Commit d2f8466

Browse files
Add Python bindings
Wrappers around oo7::Keyring/oo7::Item, giving access to both sandboxed and DBus based keyrings automatically for applications developers.
1 parent ed3e93d commit d2f8466

12 files changed

Lines changed: 964 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
#Cargo.lock
44
cli/target
55
coverage/
6+
python/.venv
7+
python/*.so
8+
python/**/__pycache__

Cargo.lock

Lines changed: 120 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"cli",
88
"pam",
99
"portal",
10+
"python",
1011
"server",
1112
]
1213

python/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "oo7-python"
3+
version.workspace = true
4+
edition = "2021"
5+
authors.workspace = true
6+
keywords.workspace = true
7+
categories.workspace = true
8+
repository.workspace = true
9+
homepage.workspace = true
10+
license.workspace = true
11+
rust-version.workspace = true
12+
description = "Python bindings for oo7"
13+
14+
[lib]
15+
name = "oo7"
16+
crate-type = ["cdylib"]
17+
18+
[dependencies]
19+
oo7_rs = { package = "oo7", path = "../client" }
20+
pyo3 = { version = "0.20", features = ["extension-module", "abi3-py38"] }
21+
pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] }
22+
tokio = { version = "1", features = ["rt-multi-thread"] }
23+
24+
[profile.release]
25+
lto = true
26+
codegen-units = 1

python/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# oo7 Python Bindings
2+
3+
Python bindings for [oo7](../client/), providing access to Secret Service API on Linux. Automatically uses a file-based keyring when running in a sandboxed environment.
4+
5+
## Installation
6+
7+
```bash
8+
cd python
9+
python3 -m venv .venv
10+
source .venv/bin/activate
11+
pip install maturin
12+
maturin develop
13+
```
14+
15+
## Usage
16+
17+
```python
18+
import asyncio
19+
import oo7
20+
21+
async def main():
22+
# Create keyring
23+
keyring = await oo7.Keyring.new()
24+
25+
# Store a secret
26+
await keyring.create_item(
27+
"My Password",
28+
{"application": "myapp", "username": "alice"},
29+
b"secret-password",
30+
replace=True
31+
)
32+
33+
# Search for items
34+
items = await keyring.search_items({"application": "myapp"})
35+
for item in items:
36+
secret = await item.secret()
37+
print(f"Secret: {secret}")
38+
39+
# Clean up
40+
await keyring.delete({"application": "myapp"})
41+
42+
asyncio.run(main())
43+
```
44+
45+
## Running Tests
46+
47+
```bash
48+
# Install dev dependencies
49+
pip install -r requirements-dev.txt
50+
51+
# Run tests
52+
pytest
53+
```
54+
55+
## Examples
56+
57+
See `tests/test_keyring.py` for more examples.
58+
59+
## License
60+
61+
MIT

0 commit comments

Comments
 (0)