pub struct ClaimTenantResolver {
pub claim_key: String,
pub single_user_fallback: bool,
}Expand description
Reference impl: derive the tenant from an AuthContext claim.
Reads a configured claim key from AuthContext.metadata (e.g.
"tenant_id", "realm", "org_id"). When single_user_fallback
is true and the claim is absent, falls back to the caller’s
user_id so single-user deployments map each user 1:1 to their own
tenant by default.
§Why single_user_fallback defaults to true
AUTHZ-DATA-S01-output Q2 leans toward the dev-safe default: a
deployment without an explicit tenant_id claim should not silently
serve cross-user data. Falling back to the user id means a
misconfigured single-user install gets per-user isolation
automatically; deployments that want a hard “claim required” gate
flip the bool to false.
Fields§
§claim_key: StringThe metadata key to look up (e.g. "tenant_id", "realm",
"org_id").
single_user_fallback: boolWhen the claim is absent, fall back to the caller’s user_id as
the tenant value. The single-user-deployment safe default.
Implementations§
Source§impl ClaimTenantResolver
impl ClaimTenantResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct with the default claim key "tenant_id" and
single_user_fallback = true. Matches the existing
AuthContext::tenant() helper’s primary lookup key.
Sourcepub fn with_claim_key(claim_key: impl Into<String>) -> Self
pub fn with_claim_key(claim_key: impl Into<String>) -> Self
Construct with a custom claim key. single_user_fallback
remains at the dev-safe true default; toggle the field
directly if a strict “claim required” gate is needed.
Trait Implementations§
Source§impl Clone for ClaimTenantResolver
impl Clone for ClaimTenantResolver
Source§fn clone(&self) -> ClaimTenantResolver
fn clone(&self) -> ClaimTenantResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more