Repository navigation
fix(network): sign in on server 0.13.1, including the all-in-one install - #13
Merged
Merged
Conversation
AdventureLog 0.13.1 removed the middleware that read X-Session-Token and now checks CSRF on login, so login answered 403 and every other request ran anonymous. Requests to the signed-in server now carry the session as a sessionid cookie, a made-up csrftoken pair (Django's double-submit check) and a same-origin Referer. X-Session-Token stays for older servers. Images send the cookie too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copies the Play upload keystore into gitignored signing/, checks its certificate against the Play draft AAB, then sets the four secrets the release job needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The all-in-one image (upstream's default install since 0.13) routes /api and /auth through the SvelteKit frontend, whose proxy drops every Set-Cookie, adds its own CSRF token and redirects trailing slashes, so the app could not sign in there. - Log in through allauth's app client, which returns the session in the body; it is a Django session key, sent as the sessionid cookie. - Probe /csrf/ once per server: JSON means Django directly, HTML means the frontend's proxy. - Behind the proxy send only the session cookie and an Origin, and no trailing slash (a 308 drops a POST; SvelteKit refuses form posts from another origin). - Sign-out stays on the browser route: the app client's DELETE leaves the session alive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AdventureLog server v0.13.1 removed the middleware that read
X-Session-Tokenand the CSRF exemptions for mobile login. Against it the app could not sign in (login answered 403 "CSRF cookie not set") and every other request ran anonymous.Changes
KtorAdventureLogNetwork: the existingHttpSendinterceptor adds what a Django session needs to every request bound for the signed-in server:Cookie: sessionid=…; csrftoken=…,X-CSRFTokenand a same-originReferer. The CSRF token is generated by the app (32 ×[A-Za-z0-9]); Django's double-submit check accepts it, so nothing new is stored and existing sessions keep working after the update.X-Session-Tokenis still sent: servers before 0.13.1 read it, and the 401 detector uses it as a marker.clearSession().ImageLoaderModule) sends thesessionidcookie too. Without it, photos of private places render blank.scripts/qa/adapter.pyauthenticates the same way.scripts/release/create_signing_secrets.shand thesigning/gitignore line, so the local keystore folder can't be committed from this branch.Tests
DjangoSessionHeadersTest(4 tests): an authenticated write, login, sign-out after the session is cleared, no cookie sent to another host. Each one was seen red with the change disabled../gradlew allTests: 774 tests, 0 failures (iOS compile included).Manual validation — Pixel 6a against the NAS on v0.13.1
Not driven: iOS (the Darwin engine has its own cookie store and may treat a manual
Cookieheader differently), transport, lodging, categories, sharing with other users.Note: the
v0.0.9-alpharelease published today was built before this fix, so it can't sign in to 0.13.1 servers.Update: upstream's all-in-one install
Upstream's default install since 0.13 is one container where
/apiand/authgo through the SvelteKit frontend. Its proxy (django-proxy.ts) drops everySet-Cookie, adds its own CSRF token and redirects URLs ending in/with a 308, so the app could not sign in there (403).da8a97ab:/auth/app/v1/auth/login), which returns the session in the body. It is a Django session key, sent as thesessionidcookie. The app route has existed since server v0.8./csrf/is probed once per server: JSON means Django directly, HTML means the proxy.Origin(SvelteKit refuses form posts without it, so photo uploads failed), and no trailing slash.DELETEanswers 401 and leaves the session alive (measured on both installs).Validated on the Pixel 6a against a public all-in-one 0.13.1 (
adventurelog.desarrollodroide.es): sign-in, Home, create a place, photo upload (rendered on a private place), collection, note, mark and unmark a region, deletes. And against the NAS (separate images): the existing session keeps working. 3 more tests (each seen red);allTests780/0 before theOrigincommit, network tests green after it.🤖 Generated with Claude Code