pub struct Authenticated { /* private fields */ }Expand description
Proof that some Authenticator verified credential material, together
with what it learned.
The claims bag carries the tenant hint (org_id) among other things.
It is a hint and not an authorization: tenancy enforcement still routes
through TenantResolver and
TenantGate, and this build does not change that
(orgs/membership are M4).
Implementations§
Source§impl Authenticated
impl Authenticated
Sourcepub fn new(
principal: Principal,
session_id: impl Into<String>,
roles: Vec<String>,
claims: Value,
) -> Self
pub fn new( principal: Principal, session_id: impl Into<String>, roles: Vec<String>, claims: Value, ) -> Self
Record a successful authentication.
Called by Authenticator impls after verifying material. The
constructor is public because authenticators live in other crates
(plexus-idp’s does), so this type is a convention-backed proof rather
than a crate-sealed one like VerifiedUser.
The strong seal is deliberately deferred: making it crate-private here
would make the trait unimplementable outside plexus-auth-core, which
is exactly the pluggability this build exists to add.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
The session identifier, empty for stateless credentials (JWTs, API keys) exactly as today’s validators leave it.
Sourcepub fn into_auth_context(self) -> AuthContext
pub fn into_auth_context(self) -> AuthContext
Project this proof into the runtime AuthContext.
This is the one place the two identity representations are tied together, and it is why they cannot diverge:
user_idisPrincipal::as_legacy_user_id— for an idp principal that is the bare UUID, byte-identical to what plexus-idp writes today.- the full namespaced principal is stamped into
metadata["principal"].
AuthContext::principal reads the stamp back, and falls back to
re-deriving it from user_id when the stamp is absent (a context
built by an older code path). Both routes yield the same value for an
idp principal — see the principal_and_user_id_agree_* tests.