pub struct AccessContext {
pub user_id: Option<String>,
pub groups: Vec<String>,
pub organization_id: Option<String>,
}Expand description
The identity a retrieval is performed as — the requester’s entitlements.
Built from the authenticated user and the groups they belong to (resolved
upstream from the auth context). Passed into the knowledge-retrieval path so
results can be filtered by AccessContext::can_access.
§Org scoping (organization_id)
The within-org user/group ACL (can_access) is the
operator’s single-tenant default and does not consult the org. A
multi-tenant relational host (e.g. SmooAI), however, needs the turn’s org
to scope RAG to that tenant’s documents — its
StorageAdapter::knowledge_for_access
reads access.organization_id to pick the right tenant before any
user/group filtering. So the org rides on the AccessContext purely to be
available to a host adapter; the built-in ACL path ignores it (org
isolation already happened upstream — every knowledge row carries an
organizationId the backend filters on). None ⇒ “no org resolved”, which a
single-tenant adapter treats exactly as today.
Fields§
§user_id: Option<String>The requester’s user id, if authenticated as a user. None for an
anonymous / system requester (which then only sees public + no-ACL docs).
groups: Vec<String>The groups the requester belongs to.
organization_id: Option<String>The organization this turn is scoped to, when resolved. Carried so a
multi-tenant host adapter’s knowledge_for_access can scope retrieval to
the right tenant; the operator’s built-in ACL ignores it (see the
type-level “Org scoping” note). None when no org is resolved (the
single-tenant / anonymous default).
Implementations§
Source§impl AccessContext
impl AccessContext
Sourcepub fn new(user_id: Option<String>, groups: Vec<String>) -> Self
pub fn new(user_id: Option<String>, groups: Vec<String>) -> Self
Build a context from an optional user id and a set of groups. The org is
left unset (None); use with_organization_id
to attach the turn’s org for a multi-tenant host.
Sourcepub fn for_user(user_id: impl Into<String>) -> Self
pub fn for_user(user_id: impl Into<String>) -> Self
A context for a specific user with no group memberships.
Sourcepub fn anonymous() -> Self
pub fn anonymous() -> Self
An anonymous requester: no user id, no groups. Sees only public and no-ACL (org-public) documents.
Sourcepub fn with_group(self, group: impl Into<String>) -> Self
pub fn with_group(self, group: impl Into<String>) -> Self
Add a group membership (builder).
Sourcepub fn with_organization_id(self, organization_id: impl Into<String>) -> Self
pub fn with_organization_id(self, organization_id: impl Into<String>) -> Self
Attach the turn’s organization (builder). Carried so a multi-tenant host
adapter’s
knowledge_for_access
can scope retrieval to that tenant. The operator’s built-in ACL ignores
it (see the type-level “Org scoping” note), so this is behavior-preserving
for the single-tenant default.
Sourcepub fn can_access(&self, acl: &DocAcl) -> bool
pub fn can_access(&self, acl: &DocAcl) -> bool
Whether this requester may read a document with the given DocAcl.
true when the doc is public, or the requester’s user id is in the
allow-list, or any of the requester’s groups is in the allow-list.
Trait Implementations§
Source§impl Clone for AccessContext
impl Clone for AccessContext
Source§fn clone(&self) -> AccessContext
fn clone(&self) -> AccessContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AccessContext
impl Debug for AccessContext
Source§impl Default for AccessContext
impl Default for AccessContext
Source§fn default() -> AccessContext
fn default() -> AccessContext
impl Eq for AccessContext
Source§impl PartialEq for AccessContext
impl PartialEq for AccessContext
Source§fn eq(&self, other: &AccessContext) -> bool
fn eq(&self, other: &AccessContext) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for AccessContext
Auto Trait Implementations§
impl Freeze for AccessContext
impl RefUnwindSafe for AccessContext
impl Send for AccessContext
impl Sync for AccessContext
impl Unpin for AccessContext
impl UnsafeUnpin for AccessContext
impl UnwindSafe for AccessContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request