Skip to content

Sign in to a server and share swarms through it - #35

Merged
evoggy merged 1 commit into
mainfrom
evoggy/auth-login
Oct 7, 2026
Merged

evoggy merged 1 commit into
mainfrom
evoggy/auth-login

Conversation

@evoggy

@evoggy evoggy commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Signing in

cfcli auth login signs in through the browser, so there's no key to copy:

  1. cfcli listens on 127.0.0.1 and opens the server's sign-in page.
  2. The user signs in there and allows "cfcli on ".
  3. The browser brings a one-time code back to cfcli, which exchanges it for an API key.

This is OAuth 2.0 authorization code with PKCE (RFC 7636) and a loopback redirect (RFC 8252). The key is stored in credentials.json next to the cfcli config, readable only by the user, and the server lists it on its API keys page, where it can be revoked.

  • cfcli auth status: who cfcli is signed in as. Exits with code 20 when it isn't signed in.
  • cfcli auth logout: revokes the key and forgets it.
  • --no-browser: only prints the link.

Shared swarms

When cfcli is signed in, swarms on the server sit next to the local ones, named <organization>/<swarm>. Local swarms stay <swarm>, and every swarm command takes either kind of ID.

  • Listing: swarm config list shows both, with where each is stored.
  • Creating, changing and deleting: create and delete with an <org>/<swarm> ID act on the server. add, remove, rename and rechannel change the shared swarm.
  • Moving: swarm config move lab org/lab shares a local swarm, and move org/lab lab takes it back, deleting it on the server after asking. move also renames a swarm, and the selected swarm follows the move.
  • Sync (cfcli settings sync on|off):
    • On, the default: commands check the server first, which is a cheap "not modified" answer when nothing changed, and upload changes right away. If someone else uploaded in between, the change is made again on their version.
    • Off: commands use this computer's copies, and swarm config pull and push sync them. push stops when someone else changed the swarm since the copy; pull --force or push --force chooses which version wins.
  • Without the server: commands use the copies and keep changes for later, so working with the Crazyflies never waits for the network.

The copies are kept in synced/ next to the config, outside the swarms folder, so Swarmkeeper and import never take them for local swarms. Shell completion lists shared swarms from the copies and never touches the network.

Testing

  • Unit tests: PKCE, the browser callback listener, and parsing of shared IDs.
  • End to end against a local server instance, with a second user changing swarms in between:
    • Sign-in, status, logout, and cancelling in the browser.
    • Creating, adding and renaming, with the other user's changes kept.
    • Moving a swarm both ways.
    • Sync off: push conflicts, pull keeping unpushed changes, and --force.
    • Offline: falling back to the copies, then uploading by itself when the server came back.
    • Deleting the selected swarm, completion without the network, and errors when signed out.

The server side is deployed at https://arc.bitcraze.io, the default server, so cfcli auth login works against it as it is.

cfcli auth login signs in through the browser: OAuth 2.0 authorization
code with PKCE (RFC 7636) and a loopback redirect (RFC 8252). cfcli opens
the server's sign-in page, the user allows it, and the key comes back to
cfcli by itself. It is stored in credentials.json next to the config,
readable only by the user. auth logout revokes it, auth status shows who
cfcli is signed in as.

Signed in, shared swarms on the server sit next to the local ones, named
<organization>/<swarm>, and every swarm command takes either:

- swarm config list shows both, with where each is stored.
- create and delete with an <org>/<swarm> ID act on the server; add,
  remove, rename and rechannel change the shared swarm.
- swarm config move shares a local swarm (lab -> org/lab), takes it back
  (org/lab -> lab, deleting it on the server) or renames one. The
  selected swarm follows.
- cfcli keeps copies of shared swarms outside the swarms folder. With
  settings sync on (the default) commands check the server first and
  upload changes right away, applying a change again on top of someone
  else's upload. With sync off they use the copies, and swarm config
  pull/push sync them; push stops when someone else changed the swarm.
- Without the server, commands use the copies and keep changes for
  later, so working with the Crazyflies never waits for the network.
@evoggy
evoggy merged commit 082a51a into main Oct 7, 2026
1 check 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