Skip to content

Add Google and magic link logins, read mod-api 3.9.0 tokens (3.0.0) - #7

Merged
alercunha merged 11 commits into
mod-audio:masterfrom
alercunha:token-format
Oct 17, 2026
Merged

alercunha merged 11 commits into
mod-audio:masterfrom
alercunha:token-format

Conversation

@alercunha

Copy link
Copy Markdown
Collaborator

Logins against mod-api 3.9.0, whose tokens carry the user in sub instead of user_id. Released CLIs read user_id and fail after every login against it, so this is a major bump: 3.0.0.

New logins

  • modcli auth login-google: Google account, opens the browser
  • modcli auth login-magiclink [--email]: sign-in link sent by email; confirm it in the browser on this machine
  • modcli auth login-forum: MOD Forum account, opens the browser (was login-sso, kept as a hidden alias so scripts keep working)
  • modcli auth login: username and password, unchanged

Every browser login requests an API token (aud=api) and sends a random state with its local_url. The local server accepts only a redirect carrying that state, so a web page probing localhost ports can't log the CLI in with someone else's token. The token is accepted from the local redirect or pasted into the terminal, whichever arrives first; when the browser runs on another machine (CLI over SSH), paste the token the result page shows.

login-sso drops -d and its confirmation prompt. -y stays on every login command as a hidden no-op.

Other changes

  • config.set_token reads sub (no fallback: tokens minted before the cutover are rejected by the API anyway) and decodes the payload as base64url
  • Modules split: auth (API calls and URLs), token_receiver (local server and paste), pages + sign_in.html (shipped as package data), cli (terminal and browser interaction)
  • Tests (uv run pytest), run in CI with a uv install and a package-data check; dev is a dependency group

Compatibility

  • Needs mod-api 3.9.0 on the server. Against an older API the browser logins don't exist and the token has no sub
  • Everyone must be on this release before mod-api 3.10, which drops user_id from tokens

Alex Cunha and others added 11 commits May 29, 2026 09:31
- New `auth login-google` and `auth login-magiclink` request API tokens
  (aud=api) with a random state the local server checks
- Browser logins open the browser and accept the token from the local
  redirect or pasted into the terminal, whichever arrives first; `login-sso`
  uses the same flow and drops -d and its confirmation prompt
- `-y` is kept on every login command as a hidden no-op for existing scripts
- MOD-branded sign-in pages, shipped as package data
- Split modules: auth (API calls), token_receiver (local server + paste),
  pages, cli (terminal and browser interaction)
- Decode the JWT payload as base64url
- Add tests, run them in CI along with a uv install and a package-data check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login-sso sends a random state like the other browser logins, and the
local server only accepts a redirect carrying it, so a web page probing
localhost ports can't log the CLI in with another account's token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mod-api 3.9.0 tokens carry the user in `sub` instead of `user_id`. No
fallback: tokens minted before the cutover are rejected by the API anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Logins need mod-api 3.9.0's token format (aud, sub); released CLIs
fail after login against it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
auth login-forum signs in through the API's /users/tokens_modforum.
login-sso stays as a hidden alias, so scripts using it keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows tries ::1 first for localhost and spends ~2s on each refused
connection, so the five-request test ran past the receiver's timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in CI

- every OS runs the oldest and newest Python, 3.11-3.13 run on Linux only
- the pip and uv jobs run the tests against the installed package
- lowest-deps job runs the tests on click 8.0 and Python 3.10
- lint job runs pylint --errors-only
- tests for the config files and the bundle tarball
- drop ubuntu-22.04, cancel superseded runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI waited a hardcoded 15 minutes, a copy of mod-api's default
MOD_MAGICLINK_TTL. POST /users/tokens_magiclink now returns expires_in,
and the wait comes from there; the forum and Google logins keep their
own five minutes, so every start returns the state and how long to wait.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@alercunha
alercunha merged commit 8a218ad into mod-audio:master Oct 17, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant