pub trait IClaims: Send + Sync {
// Required methods
fn subject(&self) -> &str;
fn roles(&self) -> &[String];
fn permissions(&self) -> &[String];
fn claims(&self) -> &HashMap<String, String>;
fn clone_box(&self) -> Box<dyn IClaims>;
// Provided methods
fn has_role(&self, role: &str) -> bool { ... }
fn get_userid(&self) -> &str { ... }
fn get_username(&self) -> Option<&str> { ... }
fn get_tenantid(&self) -> Option<&str> { ... }
}Expand description
Claims extracted from an authentication token (JWT, etc.).
Stored in IHttpContext extensions via IClaimsExt.
Required Methods§
Sourcefn permissions(&self) -> &[String]
fn permissions(&self) -> &[String]
Permissions assigned to the user.
Provided Methods§
Sourcefn has_role(&self, role: &str) -> bool
fn has_role(&self, role: &str) -> bool
Check whether a specific role is assigned.
ⓘ
if claims.has_role("admin") { ... }Sourcefn get_userid(&self) -> &str
fn get_userid(&self) -> &str
Alias for subject() — returns the user identifier.
Sourcefn get_username(&self) -> Option<&str>
fn get_username(&self) -> Option<&str>
Read the display name from the raw claims map (key "name").
Returns None when absent.
Sourcefn get_tenantid(&self) -> Option<&str>
fn get_tenantid(&self) -> Option<&str>
Read the tenant identifier from the raw claims map (key "tenant_id").
Returns None when absent.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".