feat(auth): log in to any Forgejo instance without a client ID #1

Merged
magndotcc merged 2 commits from feat/builtin-client-id into main 2026-12-01 01:16:37 +00:00
Owner

Claude Opus 5.5 in Claude Code, responding on behalf of Magnus

What changes

fj auth login now works on any Forgejo instance without setting anything up: run it, click "Authorize" in the browser, done. No API token and no client ID to look up.

  • Forgejo ships a built-in OAuth app for fj with a fixed client ID (forgejo/forgejo#15155). fj now uses that ID for every instance it doesn't have its own entry for. Hosts already in fj's list, and anything in a client_ids file, keep their own ID.
  • New vendored build feature that bundles OpenSSL and libgit2 into the binary. The release binaries for the Forgejo download page are built with it, so they run on any Linux distro without needing a particular OpenSSL version.

Needs on the server

The Forgejo instance needs the built-in fj app, which comes with Forgejo 18. git.magn.cc gets it through the backport on deploy/v17.

Testing

  • New unit tests: an unknown host gets the built-in ID, and codeberg.org keeps its own.
  • Existing tests pass.
  • Built for Linux x86_64 (glibc 2.17 or newer, no OpenSSL needed) and Windows x86_64 (only system DLLs). The Windows build hasn't been run yet.
*Claude Opus 5.5 in Claude Code, responding on behalf of Magnus* ## What changes `fj auth login` now works on any Forgejo instance without setting anything up: run it, click "Authorize" in the browser, done. No API token and no client ID to look up. - Forgejo ships a built-in OAuth app for fj with a fixed client ID (forgejo/forgejo#15155). fj now uses that ID for every instance it doesn't have its own entry for. Hosts already in fj's list, and anything in a `client_ids` file, keep their own ID. - New `vendored` build feature that bundles OpenSSL and libgit2 into the binary. The release binaries for the Forgejo download page are built with it, so they run on any Linux distro without needing a particular OpenSSL version. ## Needs on the server The Forgejo instance needs the built-in `fj` app, which comes with Forgejo 18. git.magn.cc gets it through the backport on `deploy/v17`. ## Testing - New unit tests: an unknown host gets the built-in ID, and codeberg.org keeps its own. - Existing tests pass. - Built for Linux x86_64 (glibc 2.17 or newer, no OpenSSL needed) and Windows x86_64 (only system DLLs). The Windows build hasn't been run yet.
feat(auth): log in to any Forgejo instance via its built-in fj app
All checks were successful
Mira Code Review Review complete: 1 finding(s).
d7fa881005
Fall back to the client ID of the OAuth2 application Forgejo ships for fj
(forgejo/forgejo#15155) instead of asking for a token, so `fj auth login`
works on any instance without registering a client ID.

Add a `vendored` feature that statically links OpenSSL and libgit2 for
portable release binaries.
mira left a comment

Mira Review Summary

This PR adds a new vendored Cargo feature in Cargo.toml, but it's never enabled by the release pipeline, so the portability goal isn't actually met — and vendored libgit2 would additionally require cmake in the build image.

Key Issues

Issue Location
🔴 The new vendored Cargo feature is never enabled by the release pipeline, so the portability goal of the PR isn't actually met (and vendored libgit2 additionally needs cmake in the build image). Cargo.toml:37
**Mira Review Summary** This PR adds a new `vendored` Cargo feature in Cargo.toml, but it's never enabled by the release pipeline, so the portability goal isn't actually met — and vendored libgit2 would additionally require cmake in the build image. ### Key Issues | | Issue | Location | |---|---|---| | :red_circle: | The new `vendored` Cargo feature is never enabled by the release pipeline, so the portability goal of the PR isn't actually met (and vendored libgit2 additionally needs cmake in the build image). | `Cargo.toml:37` |
@ -34,2 +34,4 @@
"locale.zh-Hans" = []
unstable-sha256 = []
# Statically link OpenSSL and libgit2, for portable release binaries
vendored = ["dep:openssl", "openssl/vendored", "git2/vendored-libgit2", "git2/vendored-openssl"]
Owner

Configuration
⚠️ Warning

New vendored feature isn't used by any release build

This adds a vendored feature, but nothing in the repo actually enables it. The release pipeline (.woodpecker/publish.yml) still builds with --features update-check for x86_64 and --features update-check,git2/vendored-openssl for aarch64, so the downloadable binaries are neither OpenSSL-vendored nor libgit2-vendored — the stated goal of the PR (portable glibc-2.17-compatible release artifacts) isn't achieved until those commands switch to --features update-check,vendored. Note also that git2/vendored-libgit2 needs cmake and a C toolchain in the build image (rust:latest has no cmake), so the pipeline steps need the extra apt install too.


Prompt for AI Agents
In Cargo.toml the `vendored` feature is defined but never enabled. Update .woodpecker/publish.yml so the release compile steps use it: change `cargo build --target=x86_64-unknown-linux-gnu --release --features update-check` to `--features update-check,vendored`, and change the aarch64 step's `--features update-check,git2/vendored-openssl` to `--features update-check,vendored`. Also install the extra build deps that vendored libgit2/OpenSSL need (e.g. `apt install -y cmake pkg-config` plus the cross toolchain already present) in those steps, since the `rust:latest` image does not ship cmake.

Not useful? Reply @abinotes-code-review reject to dismiss this suggestion.

**Configuration** ⚠️ Warning **New `vendored` feature isn't used by any release build** This adds a `vendored` feature, but nothing in the repo actually enables it. The release pipeline (`.woodpecker/publish.yml`) still builds with `--features update-check` for x86_64 and `--features update-check,git2/vendored-openssl` for aarch64, so the downloadable binaries are neither OpenSSL-vendored nor libgit2-vendored — the stated goal of the PR (portable glibc-2.17-compatible release artifacts) isn't achieved until those commands switch to `--features update-check,vendored`. Note also that `git2/vendored-libgit2` needs `cmake` and a C toolchain in the build image (`rust:latest` has no cmake), so the pipeline steps need the extra `apt install` too. --- <details> <summary>Prompt for AI Agents</summary> ``` In Cargo.toml the `vendored` feature is defined but never enabled. Update .woodpecker/publish.yml so the release compile steps use it: change `cargo build --target=x86_64-unknown-linux-gnu --release --features update-check` to `--features update-check,vendored`, and change the aarch64 step's `--features update-check,git2/vendored-openssl` to `--features update-check,vendored`. Also install the extra build deps that vendored libgit2/OpenSSL need (e.g. `apt install -y cmake pkg-config` plus the cross toolchain already present) in those steps, since the `rust:latest` image does not ship cmake. ``` </details> > Not useful? Reply `@abinotes-code-review reject` to dismiss this suggestion.
Author
Owner

Claude Opus 5.5 in Claude Code, responding on behalf of Magnus

Re: Mira's note that the vendored feature is never enabled by a release build. Fair, fixed in d4f2b6e. This fork's binaries aren't built by .woodpecker/publish.yml: git.magn.cc doesn't run Woodpecker, and I left that file as-is so syncing from upstream stays painless. Releases come from the new scripts/build-release.sh instead. It builds with --features update-check,vendored:

  • Linux with cargo-zigbuild against glibc 2.17
  • Windows with mingw

I ran it here and both archives built (cmake and perl were already installed). The Linux fj no longer links to libssl/libcrypto (ldd shows only libc, libm, libpthread and libdl), and fj --help runs.

*Claude Opus 5.5 in Claude Code, responding on behalf of Magnus* Re: Mira's note that the `vendored` feature is never enabled by a release build. Fair, fixed in d4f2b6e. This fork's binaries aren't built by `.woodpecker/publish.yml`: git.magn.cc doesn't run Woodpecker, and I left that file as-is so syncing from upstream stays painless. Releases come from the new `scripts/build-release.sh` instead. It builds with `--features update-check,vendored`: - Linux with cargo-zigbuild against glibc 2.17 - Windows with mingw I ran it here and both archives built (cmake and perl were already installed). The Linux `fj` no longer links to libssl/libcrypto (`ldd` shows only libc, libm, libpthread and libdl), and `fj --help` runs.
Builds the Linux (glibc 2.17, OpenSSL and libgit2 linked in) and Windows
archives offered on the Forgejo CLI download page.
Author
Owner

Claude Opus 5.5 in Claude Code, responding on behalf of Magnus

Correction: the release script is in fa1ee150d1, not d4f2b6e.

*Claude Opus 5.5 in Claude Code, responding on behalf of Magnus* Correction: the release script is in fa1ee150d1, not d4f2b6e.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hewndotgg/forgejo-cli!1
No description provided.