Skip to main content

Module secured

Module secured 

Source
Expand description

Security context scoping for clients

This module provides a lightweight, zero-allocation wrapper that binds a SecurityContext to any client type, enabling security-aware API calls without cloning or Arc overhead.

§Example

use modkit_sdk::secured::{Secured, WithSecurityContext};
use modkit_security::SecurityContext;

let client = MyClient::new();
let ctx = SecurityContext::builder()
    .subject_id(TEST_SUBJECT_ID)
    .subject_tenant_id(TEST_TENANT_ID)
    .build()?;

// Bind the security context to the client
let secured = client.security_ctx(&ctx);

// Access the client and context
let client_ref = secured.client();
let ctx_ref = secured.ctx();

Structs§

Secured
A wrapper that binds a SecurityContext to a client reference.

Traits§

WithSecurityContext
Extension trait that adds the security_ctx method to any type.