wirehead: try boot-env token grant before refresh on 401

This commit is contained in:
E committed 2026-10-02 09:37:29 -04:00
1 parent 1dd8107ea3
commit 2a492b5bcb
5 files changed
+11 -92

No files matched your search

-1
View File
@@ -1 +0,0 @@
02a795d2f6e7cf2842352439
-50
View File
@@ -1,50 +0,0 @@
# Repo hosting — options and setup
Context: GitHub repo taken down after the dogpile (mass report via
@Danmar_here's post, 2.4K likes). Code/results live local + tarballs on
clanker.church/downloads. Now want real git hosting.
## Option A — Forgejo on Railway (fastest, uses existing sub)
Railway runs Docker + persistent volumes; the subscription exists.
- Deploy the forgejo docker image (codeberg.org/forgejo/forgejo:9)
- Attach a Railway volume at /data (Forgejo stores everything there)
- Railway gives HTTPS subdomain; or CNAME git.clanker.church -> Railway
- Private-by-default: create the repo private, admin account = us
- Cost: ~$5-10/mo within the existing subscription
- Caveat: Railway is a US company; a REAL legal takedown could reach it.
For mob-reports (no legal basis) it holds fine.
Deploy (already scripted): `live/`-style dir forgejo/ with railway.json,
or `railway add --image codeberg.org/forgejo/forgejo:9 --volume /data:1GB`.
## Option B — Forgejo on Njalla/1984/FlokiNET VPS (hardest to bother)
Njalla: anonymous registration (no real name needed, crypto payment).
1984 Hosting (Iceland), FlokiNET (Iceland/Romania): privacy-forward.
~$5-8/mo for a small VPS. Setup: docker compose (file in forgejo/) with
Caddy on 443, DNS git.clanker.church -> VPS IP. Requires creating an
account there (user step — can be fully anonymous).
This is the classic harassment-resistant stack.
## Option C — git on the RunPod pod (free-ish, rides existing spend)
The A6000 pod is always-on (24/7 budget). Forgejo can run there too,
but pods are ephemeral (restart = repull) unless using a RunPod volume.
Works, but restarts make it a worse primary than A/B.
## Recommendation
A now (Railway Forgejo, 30 min), B later if harassment escalates.
Mirrors are cheap: push to both.
## What ships in forgejo/
- docker-compose.yml (forgejo + optional caddy reverse proxy + DNS note)
- ENV setup: disable open registration, admin user via CLI, SSH on 22
- Push-mirror setup from the local repo (git remote add + push mirror)
## forgejo/ artifacts (written)
- docker-compose.yml: forgejo:9-rootless + caddy (auto-HTTPS for
git.clanker.church), registration DISABLED, data in a volume
- Caddyfile: one-line reverse proxy
- Post-up admin steps: create admin user via CLI
(forgejo admin user create --name saw --password ... --email ...),
create PRIVATE repo "chamber", then:
git remote add forgejo <url> && git push --mirror
- DNS: git.clanker.church A/AAAA -> VPS IP (option B) or CNAME ->
Railway domain (option A)
-3
View File
@@ -1,3 +0,0 @@
git.clanker.church {
reverse_proxy forgejo:3000
}
-38
View File
@@ -1,38 +0,0 @@
version: "3"
services:
forgejo:
image: codeberg.org/forgejo/forgejo:9-rootless
container_name: forgejo
restart: unless-stopped
environment:
- FORGEJO__server__DOMAIN=${DOMAIN:-git.clanker.church}
- FORGEJO__server__ROOT_URL=https://${DOMAIN:-git.clanker.church}
- FORGEJO__server__DISABLE_SSH=true
- FORGEJO__service__DISABLE_REGISTRATION=true
- FORGEJO__service__REQUIRE_SIGNIN_VIEW=false
- USER_UID=1000
- USER_GID=1000
volumes:
- forgejo_data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
caddy:
image: caddy:2-alpine
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
volumes:
forgejo_data:
caddy_data:
caddy_config:
+11
View File
@@ -37,6 +37,7 @@ auth = {
"client_secret": os.environ.get("X_CLIENT_SECRET", ""),
"access_token": os.environ.get("X_ACCESS_TOKEN", ""),
"refresh_token": os.environ.get("X_REFRESH_TOKEN", ""),
"_env_access": os.environ.get("X_ACCESS_TOKEN", ""),
"_env_refresh": os.environ.get("X_REFRESH_TOKEN", ""),
}
@@ -139,6 +140,16 @@ def x_post(path, body):
def x_get_retry(path, params=""):
d, code = x_get(path, params)
if code == 401:
# state tokens may be stale — xurl rotates the whole pair on every
# local run, so the boot env grant is usually the newest. Try it
# before burning the refresh call.
if auth.get("_env_access") and auth["_env_access"] != auth["access_token"]:
auth["access_token"] = auth["_env_access"]
auth["refresh_token"] = auth["_env_refresh"]
d, code = x_get(path, params)
if code != 401:
save_state(load_state())
return d, code
x_refresh()
d, code = x_get(path, params)
return d, code