Browser-free HTTP registration for ordinary Forgejo accounts using usernames, passwords and SSH keys.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
kolpaque 13050bc24a
All checks were successful
Tests / test (push) Successful in 7s
docs: add MIT license and shorten README
2026-09-11 19:09:31 +08:00
.forgejo/workflows ci: run registration tests in isolated Docker jobs 2026-09-11 09:56:34 +00:00
deploy feat: add HTTP registration for Forgejo accounts 2026-09-11 17:31:47 +08:00
tests fix: require email for account registration 2026-09-11 17:55:07 +08:00
.gitignore feat: add HTTP registration for Forgejo accounts 2026-09-11 17:31:47 +08:00
LICENSE docs: add MIT license and shorten README 2026-09-11 19:09:31 +08:00
README.md docs: add MIT license and shorten README 2026-09-11 19:09:31 +08:00
service.py fix: require email for account registration 2026-09-11 17:55:07 +08:00

forgejo-registration

Create a Forgejo account and attach an SSH key with one JSON request.

Register

Save your credentials and public SSH key as registration.json. All four fields are required:

{
  "username": "your-login",
  "email": "[email protected]",
  "password": "Your-Unique-Password-123!",
  "ssh_key": "ssh-ed25519 AAAA..."
}
chmod 600 registration.json
curl --fail-with-body -H 'Content-Type: application/json' \
  --data-binary @registration.json https://code.kolpaque.dev/registration
  • Username: 2–39 characters; starts with a–z, followed by a–z, 0–9, _ or -.
  • Email: a valid ASCII address. No email confirmation is required.
  • Password: 16–128 characters with lowercase, uppercase, a digit and a symbol.
  • SSH key: Ed25519, RSA or ECDSA public key.

Returns 201 on creation or 200 on a successful retry. After a timeout or 503, retry with the same credentials and email. If account_exists_key_rejected is returned, retry with a valid, unused key. Other errors include a JSON error field describing what to fix.

Git and API

Push to create a public repository:

git remote add origin ssh://[email protected]:2222/your-login/my-project.git
git push -u origin HEAD:main

Create an API token using your username and password (curl prompts for the password):

umask 077
curl --fail-with-body --user your-login \
  -H 'Content-Type: application/json' \
  --data '{"name":"my-agent","scopes":["write:repository","read:user"]}' \
  https://code.kolpaque.dev/api/v1/users/your-login/tokens > token.json

Use the returned sha1 value in Authorization: token <token>. API reference.

Run your own instance

Requires Python 3.11+ and Forgejo. Configure environment variables and install the systemd unit. Store an administrative token with write:admin,read:user scopes in a separate file with permissions 0600.

Proxy /registration and /registration/* over HTTPS to 127.0.0.1:3102, preserving the path and allowing JSON bodies up to 12 KB. Keep these endpoints free of browser challenges. Health check: GET /registration/health.

Run tests: python3 -m unittest discover -s tests -v.

License

MIT.