Skip to main content

Module edit_auth

Module edit_auth 

Source
Expand description

Authentication and hashing helpers for the in-browser editing endpoints.

Editing is gated by a pre-shared bearer token. The token is never stored; only an Argon2 PHC hash of it lives in .mbr/config.toml (edit_token_hash). verify_token compares a presented token against that hash in constant time (Argon2’s verifier).

content_hash provides the SHA-256 used for optimistic-concurrency checks on the raw-markdown / save endpoints.

Functions§

content_hash
SHA-256 of the given bytes, hex-encoded. Used for optimistic-concurrency hashes exchanged with the editor client (X-MBR-Content-Hash).
generate_token
Generates a random 32-byte token, hex-encoded (64 chars).
hash_token
Hashes a token/password into an Argon2 PHC string (includes a random salt).
verify_token
Verifies a presented token against a stored Argon2 PHC hash.