| Crates.io | wami |
| lib.rs | wami |
| version | 0.10.0 |
| created_at | 2025-10-30 06:58:36.718391+00 |
| updated_at | 2025-10-30 06:58:36.718391+00 |
| description | Who Am I - Multicloud Identity, IAM, STS, and SSO operations library for Rust |
| homepage | https://github.com/Lsh0x/wami |
| repository | https://github.com/Lsh0x/wami |
| max_upload_size | |
| id | 1907787 |
| size | 1,265,459 |
Multi-cloud Identity and Access Management Library for Rust
WAMI (Who Am I) is a pure Rust library for Identity and Access Management (IAM), Security Token Service (STS), and Single Sign-On (SSO) operations across multiple cloud providers. Built with a domain-driven design, WAMI separates business logic from storage, making it flexible, testable, and cloud-agnostic.
Key Features:
Add this to your Cargo.toml:
[dependencies]
wami = "0.8.0"
tokio = { version = "1.0", features = ["full"] }
use wami::wami::identity::user::builder;
use wami::store::memory::InMemoryWamiStore;
use wami::store::traits::UserStore;
use wami::provider::aws::AwsProvider;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize storage
let mut store = InMemoryWamiStore::new();
let provider = AwsProvider::new();
// Build a user (pure function)
let user = builder::build_user(
"alice".to_string(),
Some("/engineering/".to_string()),
&provider,
"123456789012"
);
// Store it
let created = store.create_user(user).await?;
println!("✅ Created user: {}", created.arn);
// Retrieve it
let retrieved = store.get_user("alice").await?;
println!("✅ Retrieved: {:?}", retrieved.unwrap().user_name);
Ok(())
}
Output:
✅ Created user: arn:aws:iam::123456789012:user/engineering/alice
✅ Retrieved: "alice"
See Getting Started Guide for more examples.
WAMI includes 23 runnable examples demonstrating all major features:
| Category | Examples | Status |
|---|---|---|
| Getting Started | 01-03: Hello World, CRUD, Service Layer | ✅ All Working |
| Multi-Tenancy | 04-08: Tenants, Hierarchy, Quotas, Cross-Tenant Access, Migration | ✅ All Working |
| Multi-Cloud | 09-13: User Sync, Provider Switching, Hybrid Cloud, DR | ✅ All Working |
| Policies & RBAC | 14-17, 23: Policy Basics, Evaluation, RBAC, ABAC, Boundaries | ✅ All Working |
| STS & Federation | 18-20: Session Tokens, Role Assumption, Federation | ✅ All Working |
| SSO & Federation | 21-22: SSO Setup, Identity Providers | ✅ All Working |
Run any example with:
cargo run --example 01_hello_wami
See examples/README.md for complete documentation.
WAMI follows a clean 3-layer architecture:
┌─────────────────────────────────────────────────┐
│ Application Layer (Your Code) │
└────────────────────┬────────────────────────────┘
│
┌────────────────────┼────────────────────────────┐
│ Domain Layer │ Pure Functions │
│ │ (wami::*) │
│ • Identity │ No storage dependencies │
│ • Credentials │ Pure business logic │
│ • Policies │ Builders & validators │
│ • STS Sessions │ │
│ • Tenants │ │
└────────────────────┬────────────────────────────┘
│
┌────────────────────┼────────────────────────────┐
│ Storage Layer │ Traits & Implementations │
│ WamiStore │ In-memory, SQL, custom │
│ StsStore │ Pluggable backends │
│ TenantStore │ │
└─────────────────────────────────────────────────┘
Key Benefits:
Read more in Architecture Guide.
use wami::wami::identity::{user, group, role};
// Create user
let user = user::builder::build_user("alice".into(), None, &provider, account);
store.create_user(user).await?;
// Create group and add user
let group = group::builder::build_group("admins".into(), None, &provider, account);
store.create_group(group).await?;
store.add_user_to_group("admins", "alice").await?;
// Create role with trust policy
let role = role::builder::build_role(
"AdminRole".into(),
trust_policy,
None, None, None,
&provider, account
);
store.create_role(role).await?;
use wami::wami::credentials::access_key;
use wami::wami::sts::session;
// Create access keys
let key = access_key::builder::build_access_key("alice".into(), &provider, account);
store.create_access_key(key).await?;
// Create temporary session
let session = session::builder::build_session(
"session-123".into(),
"AKIA...".into(),
"secret".into(),
3600, // 1 hour
Some(role_arn),
&provider, account
);
store.create_session(session).await?;
use wami::wami::tenant::{Tenant, TenantId};
// Create parent tenant
let parent_id = TenantId::root("acme-corp");
let parent = Tenant { id: parent_id.clone(), /* ... */ };
store.create_tenant(parent).await?;
// Create child tenant
let child_id = parent_id.child("engineering");
let child = Tenant { id: child_id.clone(), parent_id: Some(parent_id), /* ... */ };
store.create_tenant(child).await?;
// Query hierarchy
let descendants = store.get_descendants(&parent_id).await?;
wami/
├── src/
│ ├── wami/ # Domain layer (pure functions)
│ │ ├── identity/ # Users, groups, roles
│ │ ├── credentials/ # Access keys, MFA, certificates
│ │ ├── policies/ # IAM policies
│ │ ├── sts/ # Sessions, temporary credentials
│ │ ├── sso_admin/ # SSO configuration
│ │ └── tenant/ # Multi-tenant models
│ │
│ ├── store/ # Storage layer
│ │ ├── traits/ # Storage trait definitions
│ │ └── memory/ # In-memory implementations
│ │
│ ├── provider/ # Cloud provider abstractions
│ │ ├── aws.rs
│ │ ├── gcp.rs
│ │ └── azure.rs
│ │
│ └── error.rs # Error types
│
├── docs/ # 📚 All documentation
├── examples/ # Working code examples
└── tests/ # Integration tests
Run the full test suite:
cargo test
WAMI has 376 tests (all passing ✅) covering:
Contributions are welcome! Please:
git checkout -b feature/amazing-feature)cargo test)cargo clippy and cargo fmtSee Contributing Guide for more details.
See Issues Tracker for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Found a security issue? Please see Security Policy for reporting guidelines.