Skip to main content

WithSecurityContext

Trait WithSecurityContext 

Source
pub trait WithSecurityContext {
    // Required method
    fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, Self>
       where Self: Sized;
}
Expand description

Extension trait that adds the security_ctx method to any type.

This trait enables any client to be wrapped with a security context using a fluent API: client.security_ctx(&ctx).

§Example

use modkit_sdk::secured::WithSecurityContext;

let secured = my_client.security_ctx(&security_context);

Required Methods§

Source

fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, Self>
where Self: Sized,

Binds a security context to this client, returning a Secured wrapper.

§Arguments
  • ctx - Reference to the security context to bind
§Returns

A Secured wrapper containing references to both the client and context.

§Example
let secured = client.security_ctx(&ctx);
assert_eq!(secured.ctx().subject_tenant_id(), ctx.subject_tenant_id());

Implementors§