Skip to main content

current_identity

Function current_identity 

Source
pub fn current_identity() -> Option<String>
Expand description

Get the current caller’s identity name (set by RBAC middleware). Returns None outside an RBAC-scoped request context.

An empty identity is treated as absent and yields None, matching current_role, current_token and current_sub. This matters because current_sub().or_else(current_identity) is a natural way to resolve a stable per-user key, and an empty string returned here would defeat the caller’s None check while looking correct.

This normalises the accessor only. A configured AuthIdentity may still carry an empty name, which remains significant elsewhere (session-binding fingerprints, admin summaries, audit logs).