wardn login

Sign in from a machine through the browser, and sign out.

wardn login signs this machine in with a browser, so you never copy a token by hand. See Runners for the whole flow.

wardn login --server https://wardn.example.com

It asks the server for a code, opens your browser on the approval page, and waits. You choose the organization and approve; the CLI collects a personal API token named after the machine. The token acts as you in that organization and is limited to what you may do there.

FlagMeaning
--serverThe server to sign in to. Defaults to --api, WARDN_API_URL, or the sign-in you made last.
--codeDo not open a browser: print an address and a short code to approve from any browser. Also what a machine with no display does by itself.
--nameWhat the approval page calls this machine. Defaults to the hostname.

Where the token is kept

In the system keychain: Keychain on macOS, Credential Manager on Windows, the Secret Service (GNOME Keyring, KWallet) on Linux. A machine without one keeps it in credentials.json in the CLI's configuration directory (~/.config/wardn, or WARDN_CONFIG_DIR), readable only by you, and the command says which it used. Set WARDN_NO_KEYRING=1 to always use the file.

Using the sign-in

A command with no --token and no WARDN_TOKEN uses the stored token, for --api if given and otherwise for the server you signed in to last. --token and WARDN_TOKEN always win, so scripts and cluster shell pods are unchanged.

How the sign-in is protected

The sign-in follows the OAuth device flow (RFC 8628).

  • Short-lived and used once. A code lasts ten minutes. The CLI's polling code is a long random value that the server keeps only as a hash, and the token's secret is handed over once.
  • Paced. The CLI asks about every three seconds. A client that asks sooner is told to slow down and must wait longer, and each address has a limit on how often it may start a sign-in or ask.
  • You see who is asking. The approval page shows when the sign-in started, the address it came from and the client that started it. If you did not just run wardn login, deny it.
  • Codes cannot be guessed. A short code is one of about 378 billion. Someone who enters ten codes that do not exist is stopped, then allowed one a minute.
  • Nothing is left behind. If you approve but the CLI never collects the token, for example because the terminal was closed, Wardn revokes the token within a minute of the code expiring.
  • Recorded. Approving, denying, the CLI collecting its token, and a token revoked because it was never collected all appear in your organization's Activity. Starting a sign-in and polling happen before anyone has signed in, so they go to the server's log with the client's address.

wardn logout

wardn logout forgets the stored sign-in and revokes its token. If the token cannot be revoked from the CLI it says so; revoke it in Settings, API tokens.

An approval page is opened with the code in its address, /device?code=.... Check the code matches your terminal before you approve: approving lets that machine act as you.

On this page