Expand description
§modo::client
Client-context types and helpers shared across HTTP, audit, and session code paths.
Provides:
ClientInfo— structured client metadata (IP, user-agent, parsed device fields, server-computed fingerprint). Populated automatically in handlers viaFromRequestParts, or built manually for non-HTTP contexts (background jobs, CLI tools).parse_device_name/parse_device_type—User-Agentclassifiers.compute_fingerprint— SHA-256 hash of UA + Accept-Language + Accept-Encoding for session-hijack detection.header_str— small helper that reads a header as&str, returning""when absent or non-UTF-8. Useful for code paths that already hold a&HeaderMapand need the same defaultingClientInfouses internally.
Used by crate::audit (persisted with audit events) and
crate::auth::session (session creation, fingerprint validation).
§Quick start
use modo::client::ClientInfo;
async fn handler(info: ClientInfo) -> String {
format!(
"{} from {}",
info.device_name_value().unwrap_or("Unknown"),
info.ip_value().unwrap_or("?"),
)
}Structs§
- Client
Info - Client request context: IP, user-agent, parsed device fields, and a server-computed browser fingerprint.
Functions§
- compute_
fingerprint - Compute a SHA-256 fingerprint from three request headers.
- header_
str - Extract a header value as a string slice, returning
""when absent or non-UTF-8. - parse_
device_ name - Derive a human-readable device name from the
User-Agentstring. - parse_
device_ type - Classify the device type from the
User-Agentstring.