hodei-authz-sdk-hrn
Core types for the Hodei authorization framework.
Overview
hodei-authz-sdk-hrn provides fundamental types used across the Hodei framework, most notably the HRN (Hodei Resource Name) - a resource naming system inspired by AWS ARN.
Features
- HRN (Hodei Resource Name): Unique identifiers for resources
- Builder Pattern: Easy construction of HRNs
- Serialization: Full serde support
- Parsing: Parse HRNs from strings
- Zero Dependencies: No heavy dependencies (only serde and thiserror)
Installation
[]
= "0.1"
Usage
Creating an HRN
use Hrn;
let hrn = builder
.service
.tenant_id
.resource
.unwrap
.build
.unwrap;
println!;
// Output: hrn:hodei-authz-sdk:users-api:global:tenant-123:user/alice
Parsing an HRN
use Hrn;
let hrn: Hrn = "hrn:hodei-authz-sdk:docs:global:tenant-1:document/doc-1"
.parse
.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Serialization
use Hrn;
use serde_json;
let hrn = builder
.service
.tenant_id
.resource
.unwrap
.build
.unwrap;
let json = to_string.unwrap;
let deserialized: Hrn = from_str.unwrap;
assert_eq!;
HRN Format
hrn:hodei-authz-sdk:{service}:global:{tenant_id}:{resource_type}/{resource_id}
- partition: Always "hodei-authz-sdk"
- service: Service name (e.g., "users-api", "documents")
- region: Always "global" (reserved for future use)
- tenant_id: Tenant identifier for multi-tenancy
- resource_type: Type of resource (e.g., "user", "document")
- resource_id: Unique identifier within the resource type
Features
Optional Features
sqlx: Enables PostgreSQL type support for HRN
[]
= { = "0.1", = ["sqlx"] }
License
MIT OR Apache-2.0