pub struct Session { /* private fields */ }Expand description
Parsed session variables from the incoming request.
In a Hasura + Knative setup, these come from the JWT claims forwarded
by Hasura as session_variables in the action payload:
{
"x-hasura-user-id": "user-42",
"x-hasura-role": "customer"
}§Trust boundary (security-critical)
This framework does NOT authenticate. A Session is built from
whatever the transport hands it — HTTP request headers, gRPC metadata, or
the request payload’s session_variables. None of that is verified here.
Identity values such as x-hasura-user-id and x-hasura-role are
trusted at face value by Session::user_id, Session::role, and any
handler that reads them.
You MUST deploy this behind a trusted proxy / API gateway (e.g. Hasura, or an authenticating ingress) that:
- Strips any client-supplied
x-hasura-*headers/metadata on inbound requests, and - Injects only authenticated identity claims it has verified.
Without that proxy, any caller can set x-hasura-user-id /
x-hasura-role and assume any identity or role.
§Source precedence
When a request carries identity in more than one place, the trusted transport channel wins over the client-controlled payload:
- gRPC: transport metadata (trusted, proxy-injected) overrides payload
session_variables(client-controlled). Seegrpc::build_session. - HTTP: request headers populate the session; the proxy is responsible
for ensuring those headers are authenticated. See
http::session_from_headers.
Treat metadata/headers as trusted only insofar as your proxy guarantees it; treat the request body as never trustworthy for identity.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
Blanket Implementations§
Source§impl<T> AggregateBuilder for T
impl<T> AggregateBuilder for T
fn aggregate<A: Aggregate>(self) -> AggregateRepository<Self, A>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Queueable for T
impl<T> Queueable for T
Source§fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>
fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>
.aggregate::<T>() for per-aggregate serialization over the async
repository surface.