Reads the signed-in principal of the request's session, without running the authentication strategy chain.
This is the snapshot recorded at sign-in: an implementation's per-request
re-checks (@setu-ts/auth-plugin's refreshPrincipal and sessionStamp)
do not run here, so a session they have ended can still be returned.
Decide who may act from ctx.request.user, which the strategy chain
re-checked.
The request context whose session is read
The principal, or null when the session holds no identity
Reads the pending second-factor record, if one exists.
A pending record is written by IAuthSessionService.signIn when
the mfa.required option answers true and the methods hold no second
factor. It is consumed by the package's own verifiers (TOTP, passkeys),
which promote it to the signed-in key after a successful factor check.
The request context whose session is read
The pending record, or null when none is stored or it has
expired (an expired record can never be completed, so it is not reported)
Records principal as the signed-in identity of the request's session.
The write happens inside the session, so it is committed by the session
middleware after the handler returns — the service never issues a
Set-Cookie itself. The session id is regenerated, because a session id a
caller planted before authentication must not survive into the
authenticated session (session fixation).
When the signIn.mfa.required option answers true and the methods hold
no second factor, the principal is stored in a pending record instead and
the outcome is { status: 'second-factor-required' }.
Requires the session middleware to have run for this request; it throws
otherwise, exactly as ISessionService.from does.
The request context whose session signs in
The identity to record
The methods that authenticated it
Resolves once the record has been written
Ends the signed-in session.
What is revoked depends on the session strategy, and callers must know
which one they run. On the store strategy (SessionPlugin({ store: … }))
the stored entry is deleted, so a cookie copied before this call stops
authenticating immediately. On the default encrypted-cookie strategy there
is nothing server-side to delete: a cookie copied before sign-out keeps
authenticating until its maxAge expires, because the payload the cookie
carries is itself the session. Use the store strategy wherever sign-out has
to mean revocation.
The request context whose session ends
The one owner of "who is signed in" for a session.
Registered by
AuthPluginwhen itssignInoption is configured. A password login, a federated sign-in, a passkey assertion and a SAML assertion all record their principal throughIAuthSessionService.signIn, and the plugin's own authentication strategy reads that record back — so an application needs no hand-written middleware to turn its session into a principal.Example
Since
0.8.0