pub struct Principal { /* private fields */ }Expand description
The authenticated caller, as seen by the routing/tenancy SPI.
Carries a stable PrincipalId and a small set of attributes an
implementer may key tenancy decisions on (e.g. a tenant id derived from the
client certificate). It never carries the raw credential (token,
certificate bytes): those are consumed by the authenticator and dropped, so
nothing secret reaches the SPI or telemetry (docs/05 §7, NFR-S2).
§Examples
use osproxy_core::PrincipalId;
use osproxy_spi::{Principal, PrincipalAttr};
let p = Principal::new(PrincipalId::from("svc-ingest"))
.with_attr(PrincipalAttr::new("tenant", "acme"));
assert_eq!(p.id().as_str(), "svc-ingest");
assert_eq!(p.attr("tenant"), Some("acme"));
assert_eq!(p.attr("missing"), None);Implementations§
Source§impl Principal
impl Principal
Sourcepub fn new(id: PrincipalId) -> Self
pub fn new(id: PrincipalId) -> Self
Constructs a principal with no attributes.
Sourcepub fn with_attr(self, attr: PrincipalAttr) -> Self
pub fn with_attr(self, attr: PrincipalAttr) -> Self
Adds an attribute (builder style).
Sourcepub fn id(&self) -> &PrincipalId
pub fn id(&self) -> &PrincipalId
The principal’s stable id.
Trait Implementations§
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
Mutably borrows from an owned value. Read more