Reuse TOKEN_FOR_GITEA for the wiki when no wiki secret exists #49

Merged
Tirsvad merged 2 commits from mil-005-wiki-token-fallback into main 2026-10-10 04:05:12 +02:00
Owner

Lets the Publish wiki workflow reuse TOKEN_FOR_GITEA, so no new secret is needed.

Changes

  • .gitea/workflows/publish-wiki.yml: WIKI_CREDENTIALS is secrets.TOKEN_FOR_GITEA_WIKI || secrets.TOKEN_FOR_GITEA. A separate wiki secret still wins if one is added.
  • tools/publish_wiki.py: the missing-token message is now "No token for the wiki: set TOKEN_FOR_GITEA_WIKI, or TOKEN_FOR_GITEA."; the tests follow.
  • guides/credentials.md, guides/troubleshooting.md and README.md describe the fallback and the scope it needs.

Wiki pages changed (rule 8)

English: Home, Credentials, Troubleshooting. Danish and Bahasa Malaysia: Home, Credentials, Troubleshooting (retranslated, structure unchanged apart from one added troubleshooting row). Full suite: 137 passed.

Notes

  • Writing wiki pages needs write:repository and write access to this repository. TOKEN_FOR_GITEA is documented as read:repository; if it is read-only, the publish fails with a categorised [permissions] HTTP 403 and writes nothing.
  • Raising that token's scope also gives the metadata sync write access. A separate TOKEN_FOR_GITEA_WIKI for a dedicated user keeps the sync token read-only; S05 decides.
  • MIL-005 task 2 and ADR-0001 still describe a separate secret; amending them needs a version row and review, so they are unchanged.
  • The dispatch runs the workflow from main, so the fallback takes effect after this merges. Publishing and verifying (#38) follows.

Token shape in a 401 (second commit)

When Gitea rejects the wiki token, the error now ends with Token shape: N characters, ...: the length, whether it looks like a Gitea token (40 hexadecimal characters) and the likely storage mistake (only mask characters, NAME=value, quotes, whitespace). No character of the token is printed, and 403 and configuration errors are unchanged. Tests: 144 passed.

Refs #42
Refs #38

Lets the **Publish wiki** workflow reuse `TOKEN_FOR_GITEA`, so no new secret is needed. ## Changes - `.gitea/workflows/publish-wiki.yml`: `WIKI_CREDENTIALS` is `secrets.TOKEN_FOR_GITEA_WIKI || secrets.TOKEN_FOR_GITEA`. A separate wiki secret still wins if one is added. - `tools/publish_wiki.py`: the missing-token message is now "No token for the wiki: set TOKEN_FOR_GITEA_WIKI, or TOKEN_FOR_GITEA."; the tests follow. - `guides/credentials.md`, `guides/troubleshooting.md` and `README.md` describe the fallback and the scope it needs. ## Wiki pages changed (rule 8) English: Home, Credentials, Troubleshooting. Danish and Bahasa Malaysia: Home, Credentials, Troubleshooting (retranslated, structure unchanged apart from one added troubleshooting row). Full suite: 137 passed. ## Notes - Writing wiki pages needs `write:repository` and write access to this repository. `TOKEN_FOR_GITEA` is documented as `read:repository`; if it is read-only, the publish fails with a categorised `[permissions]` HTTP 403 and writes nothing. - Raising that token's scope also gives the metadata sync write access. A separate `TOKEN_FOR_GITEA_WIKI` for a dedicated user keeps the sync token read-only; S05 decides. - MIL-005 task 2 and ADR-0001 still describe a separate secret; amending them needs a version row and review, so they are unchanged. - The dispatch runs the workflow from `main`, so the fallback takes effect after this merges. Publishing and verifying (#38) follows. ## Token shape in a 401 (second commit) When Gitea rejects the wiki token, the error now ends with `Token shape: N characters, ...`: the length, whether it looks like a Gitea token (40 hexadecimal characters) and the likely storage mistake (only mask characters, `NAME=value`, quotes, whitespace). No character of the token is printed, and 403 and configuration errors are unchanged. Tests: 144 passed. Refs #42 Refs #38
Tirsvad added 1 commit 2026-10-10 03:36:52 +02:00
Reuse TOKEN_FOR_GITEA for the wiki when TOKEN_FOR_GITEA_WIKI is absent
Validate workflows / validate (pull_request) Successful in 15s
2eb852cfc6
The Publish wiki workflow now reads secrets.TOKEN_FOR_GITEA_WIKI ||
secrets.TOKEN_FOR_GITEA, so the existing token can publish the wiki when it
has write:repository. Update the missing-token message, the credentials and
troubleshooting guides, the README, the tests and the affected English
wiki pages with their Danish and Bahasa Malaysia translations.

Task: MIL-005#8
Tirsvad added 1 commit 2026-10-10 04:03:16 +02:00
Show the shape of a rejected wiki token in the error
Validate workflows / validate (pull_request) Successful in 14s
0135b2763c
When Gitea answers 401, add the token's length and likely storage mistakes
(masked text, NAME=value, quotes, whitespace) to the message, without any
character of the token, so a wrongly stored secret can be recognised from
the log.

Task: MIL-005#8
Tirsvad merged commit 1a9c9a32e7 into main 2026-10-10 04:05:12 +02:00
Tirsvad deleted branch mil-005-wiki-token-fallback 2026-10-10 04:05:12 +02:00
Sign in to join this conversation.