Repository navigation
Sign in to a server and share swarms through it - #35
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signing in
cfcli auth loginsigns in through the browser, so there's no key to copy:127.0.0.1and opens the server's sign-in page.This is OAuth 2.0 authorization code with PKCE (RFC 7636) and a loopback redirect (RFC 8252). The key is stored in
credentials.jsonnext 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.swarm config listshows both, with where each is stored.createanddeletewith an<org>/<swarm>ID act on the server.add,remove,renameandrechannelchange the shared swarm.swarm config move lab org/labshares a local swarm, andmove org/lab labtakes it back, deleting it on the server after asking.movealso renames a swarm, and the selected swarm follows the move.cfcli settings sync on|off):swarm config pullandpushsync them.pushstops when someone else changed the swarm since the copy;pull --forceorpush --forcechooses which version wins.The copies are kept in
synced/next to the config, outside theswarmsfolder, so Swarmkeeper andimportnever take them for local swarms. Shell completion lists shared swarms from the copies and never touches the network.Testing
pullkeeping unpushed changes, and--force.The server side is deployed at https://arc.bitcraze.io, the default server, so
cfcli auth loginworks against it as it is.