pub struct CallerContext {
pub read_scope: ReadScope,
pub is_admin: bool,
pub isolation_config: Arc<IsolationConfig>,
pub identity: Option<String>,
pub grant_selectors: Arc<[String]>,
}Expand description
Bundles the orthogonal authorization inputs make_session_context and friends need –
audience scope (read_scope) and the is_admin mutating-function-registration capability –
into one struct instead of adjacent, transposable positional parameters.
Required (not Option/defaulted) at every call site by design: a defaulting parameter would
let a future call site inherit ReadScope::All by omission, which is exactly the failure this
seam exists to prevent. Every call site must state its scope explicitly, via one of the three
constructors below or a resolved value from a ReadPolicy.
Fields§
§read_scope: ReadScopeThe audience scope to plan queries under. Consumed by
super::ownership_rewrite::OwnershipRewrite inside query.rs::make_session_context.
is_admin: boolWhether the caller may use the five mutating lakehouse UDTFs/UDFs.
isolation_config: Arc<IsolationConfig>Per-service data-isolation deployment config (MICROMEGAS_PUBLIC_VIEW_SETS) – resolved
once at server startup, not per request, but bundled here rather than as a new
make_session_context parameter: per-request resolved values ride the context,
per-service objects live on the service, and this rides along with read_scope at every
real call site anyway.
identity: Option<String>The caller’s identity, as recorded in deny_queries’s created_by column. None on
internal/maintenance paths – such a caller cannot call deny_queries, which requires
Some. One string, not a struct: created_by is the only consumer, so a richer identity
type would be written at every construction site and read nowhere.
grant_selectors: Arc<[String]>The grant selectors this caller matches – "*", "user:<email>" when an email is present,
and one "group:<g>" per claimed group – precomputed by rust/public from the
AuthContext (micromegas_auth::policy::caller_selectors), so micromegas-analytics never
needs the auth crate. Empty for internal and maintenance callers and for a request with no
AuthContext at all (--disable-auth). Consumed by list_audience_grants()
(list_audience_grants_table_function.rs); admins do not need it – they see every row.
Implementations§
Source§impl CallerContext
impl CallerContext
Sourcepub fn internal() -> CallerContext
pub fn internal() -> CallerContext
For background/materialization callers that are not serving a user request at all
(is_admin: false, ReadScope::All). Distinct from Self::maintenance only in
is_admin – use this for internal call sites that must not register the mutating
UDTFs/UDFs.
Sourcepub fn maintenance() -> CallerContext
pub fn maintenance() -> CallerContext
For background/materialization callers performing maintenance work (is_admin: true,
ReadScope::All) – never a user session.
Trait Implementations§
Source§impl Clone for CallerContext
impl Clone for CallerContext
Source§fn clone(&self) -> CallerContext
fn clone(&self) -> CallerContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CallerContext
impl RefUnwindSafe for CallerContext
impl Send for CallerContext
impl Sync for CallerContext
impl Unpin for CallerContext
impl UnsafeUnpin for CallerContext
impl UnwindSafe for CallerContext
Blanket Implementations§
impl<T> Allocation for T
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,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].