mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-19 10:45:03 +01:00
share: the key never travels in a URL
The share page used to put the key in the API path, and every embedded
picture or video carried it in its src, so a reverse proxy's access log
held whole links. The page now sends the key in the body of
POST /api/share/{token}. The answer sets a diary_share cookie
(__Secure- over HTTPS) scoped to /api/share/{token}/, HttpOnly,
SameSite=Strict, good for twelve hours, and signed over the key's hash.
Media is served from /api/share/{token}/media/{id} only to a browser
holding that cookie, so minting a new key or unsharing voids it.
The old /api/share/{token}/{key} routes are gone; links themselves are
unchanged, since the key was always in their fragment.
This commit is contained in:
1 parent
fe1b12042d
commit
947cc2ba96
8 files changed
+257
-51
No files matched your search
+5
-5
@@ -338,11 +338,11 @@ async fn deadline(
|
||||
/// Below the ten seconds `docker stop` waits before it sends SIGKILL.
|
||||
const SHUTDOWN_GRACE: std::time::Duration = std::time::Duration::from_secs(8);
|
||||
|
||||
/// A request path as it may go into the log: a share link's token and key are
|
||||
/// the whole of its secret, and the key is kept out of every log on purpose —
|
||||
/// it travels in the URL fragment so that no server ever sees it, except this
|
||||
/// one's API, which must not write it down either. Query strings, which carry
|
||||
/// search terms, are never logged at all.
|
||||
/// A request path as it may go into the log: a share link's token is half of
|
||||
/// its secret. The other half, the key, never travels in a path — it rides in
|
||||
/// the URL fragment, which no server sees, and then in the body of the read
|
||||
/// that trades it for a cookie. Query strings, which carry search terms, are
|
||||
/// never logged at all.
|
||||
fn loggable(path: &str) -> &str {
|
||||
if path.starts_with("/api/share/") {
|
||||
"/api/share/…"
|
||||
|
||||
Reference in new issue
Block a user