Skip to main content

systemprompt_models/execution/context/
credential.rs

1//! Which credential authenticated a request. `browser_session` is set only
2//! when the token arrived as the session cookie *and* carries the
3//! `browser_session` claim the first-party web login mints; `cookie_transport`
4//! records the cookie alone. The auth middleware sets both, never from a
5//! header the caller names; they decide whether document calls run as the
6//! person or as an agent.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11use super::RequestContext;
12
13impl RequestContext {
14    #[must_use]
15    pub const fn with_browser_session(mut self) -> Self {
16        self.auth.browser_session = true;
17        self
18    }
19
20    #[must_use]
21    pub const fn is_browser_session(&self) -> bool {
22        self.auth.browser_session
23    }
24
25    #[must_use]
26    pub const fn with_cookie_transport(mut self) -> Self {
27        self.auth.cookie_transport = true;
28        self
29    }
30
31    #[must_use]
32    pub const fn is_cookie_transport(&self) -> bool {
33        self.auth.cookie_transport
34    }
35
36    #[must_use]
37    pub const fn with_token_exp(mut self, token_exp: i64) -> Self {
38        self.auth.token_exp = Some(token_exp);
39        self
40    }
41
42    #[must_use]
43    pub const fn token_exp(&self) -> Option<i64> {
44        self.auth.token_exp
45    }
46}