Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
corteq-onepassword
This is a 1Password SDK wrapper for Rust applications. This does NOT use the 1Password CLI! Providing a safe interface to 1Password secrets using FFI bindings for the official 1Password SDK Core library.
Features
- Secure by default - Secrets wrapped in
SecretStringwith automatic memory zeroization - Simple API - Retrieve secrets with a single function call
- Thread-safe - Client is
Send + Syncfor use in async applications - Builder pattern - Flexible configuration with sensible defaults
- Type-safe - Compile-time guarantees for secret handling
Quick Start
use ;
async
Installation
Add to your Cargo.toml:
[]
= "0.1"
Installing from crates.io
When you install this crate from crates.io, the native library is not included
(due to crates.io's 10MB size limit). The library is automatically downloaded during
cargo build:
- First build - Downloads the library from PyPI (~15-18MB)
- Subsequent builds - Uses the cached library in your target directory
Requirements
- Network access during first build to:
pypi.org(package metadata)files.pythonhosted.org(library download)
Offline Builds
For environments without network access:
-
Download the library on a connected machine:
# Download for your platform (example for Linux x86_64) | \ | \ | -
Set the library path before building:
Authentication
This crate uses 1Password service account tokens. Personal account tokens are not supported.
Environment Variable (Recommended)
let client = from_env?.connect.await?;
Explicit Token (Not recommended for production use!)
let client = from_token
.connect
.await?;
Secret References
Secrets are referenced using the op://vault/item/field format:
op://Production/Database/password- Simple referenceop://Production/Database/admin/password- Section-scoped reference
See https://developer.1password.com/docs/cli/secret-reference-syntax/
API
Single Secret
let api_key = client.secret.await?;
Batch Resolution
let secrets = client.secrets.await?;
let host = secrets.expose_secret;
let user = secrets.expose_secret;
let pass = secrets.expose_secret;
Named Resolution
let secrets = client.secrets_named.await?;
let host = secrets.get.unwrap.expose_secret;
Sharing the Client
The client is thread-safe and can be shared via Arc:
use Arc;
let client = new;
let client1 = clone;
let client2 = clone;
join!;
Feature Flags
blocking- Enable synchronous API viaconnect_blocking()tracing- Enable tracing spans for observability
[]
= { = "0.1", = ["blocking"] }
Platform Support
| Platform | Architecture | Status |
|---|---|---|
| Linux | x86_64 | ✅ Supported |
| Linux | aarch64 | ✅ Supported |
| macOS | x86_64 | ✅ Supported |
| macOS | aarch64 | ✅ Supported |
| Windows | - | ❌ Not supported |
| Alpine | - | ❌ Not supported (musl) |
Build Process
The build script looks for the 1Password SDK native library in this order:
ONEPASSWORD_LIB_PATH- Custom path via environment variable- Bundled libraries - Pre-downloaded in
src/libs/{platform}/ - PyPI download - Automatic download at build time (requires network)
Bundled Libraries (Git LFS)
This repository includes pre-downloaded libraries for all supported platforms in src/libs/:
src/libs/
├── linux-x86_64/libop_uniffi_core.so (~18MB)
├── linux-aarch64/libop_uniffi_core.so (~17MB)
├── macos-x86_64/libop_uniffi_core.dylib (~16MB)
└── macos-aarch64/libop_uniffi_core.dylib (~15MB)
These files are tracked with Git LFS due to their size. After cloning:
Why bundle libraries?
- crates.io size limit: crates.io enforces a 10MB limit per crate, so we can't include libraries there
- Offline builds: No network access required when using bundled libraries
- Build reproducibility: Known library versions with verified checksums
Refreshing Bundled Libraries
To update the bundled libraries (e.g., for a new SDK version):
This script fetches all 4 platform libraries from PyPI with SHA256 verification.
PyPI Fallback
If bundled libraries are not found, the build script downloads from PyPI:
- Fetches metadata from PyPI's JSON API
- Downloads the appropriate wheel for your target platform
- Verifies the SHA256 checksum
- Extracts the native library
Network Requirements
When downloading from PyPI, network access is required to:
pypi.org- Package metadata and checksumsfiles.pythonhosted.org- Library downloads
Custom Library Path
For custom library locations:
Security
- Tokens wrapped in
SecretStringand zeroized on drop - Secrets never appear in logs or error messages
- Debug implementations redact sensitive data
- Native library verified via SHA256 checksum at build time
Error Handling
All errors are typed and implement std::error::Error:
use Error;
match client.secret.await
Troubleshooting
"Could not find libop_uniffi_core.so"
This error occurs when the native library cannot be located at runtime.
Solutions:
-
Rebuild the crate - The build script downloads the library automatically:
&& -
Check network access - The build script needs to reach PyPI:
-
Set custom path - If you have the library elsewhere:
Build Script Download Failed
If the automatic download fails during build:
- Check your network connection
- Check if PyPI is accessible:
curl https://pypi.org - Try setting
ONEPASSWORD_SKIP_DOWNLOAD=1and provide the library manually viaONEPASSWORD_LIB_PATH
License
MIT