pub struct Principal {
pub user_id: String,
pub org_id: String,
pub role: Role,
pub display_name: Option<String>,
pub groups: Vec<String>,
}Expand description
Fields§
§user_id: StringStable user id (the JWT sub).
org_id: StringThe organization this principal belongs to (the JWT org / org_id).
Every admin read is filtered to this org.
role: RoleThe principal’s role in the org.
display_name: Option<String>Optional human-readable name (the JWT name).
groups: Vec<String>The groups the principal belongs to (the JWT groups claim). These are
the entitlements the document-level ACL layer matches against: a
document scoped to group github:owner/repo is readable only by a
principal carrying that group. Empty when the token has no groups
claim (the principal then sees only org-public + user-scoped docs).
Implementations§
Source§impl Principal
impl Principal
Sourcepub fn new(
user_id: impl Into<String>,
org_id: impl Into<String>,
role: Role,
display_name: Option<String>,
) -> Self
pub fn new( user_id: impl Into<String>, org_id: impl Into<String>, role: Role, display_name: Option<String>, ) -> Self
Construct a principal (mostly for tests + the no-auth path).
Sourcepub fn with_groups<I, S>(self, groups: I) -> Self
pub fn with_groups<I, S>(self, groups: I) -> Self
Attach group memberships to this principal (builder). The groups flow
into access_context so the document-level ACL
layer can match a group-scoped document.
Sourcepub fn access_context(&self) -> AccessContext
pub fn access_context(&self) -> AccessContext
Map this principal to the document-level AccessContext used by the
knowledge-retrieval ACL layer. Both the user id and the principal’s
groups carry through, so a retrieval as this principal can match a
document scoped to the user or to any group the principal belongs to
(the JWT groups claim — see [Claims]).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Principal
impl<'de> Deserialize<'de> for Principal
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Principal
impl StructuralPartialEq for Principal
Auto Trait Implementations§
impl Freeze for Principal
impl RefUnwindSafe for Principal
impl Send for Principal
impl Sync for Principal
impl Unpin for Principal
impl UnsafeUnpin for Principal
impl UnwindSafe for Principal
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> FromResponse for Twhere
T: DeserializeOwned,
impl<T> FromResponse for Twhere
T: DeserializeOwned,
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