Authenticate to Chronicle with Cratis CLI
Chronicle supports two authentication modes:
- User login — a human operator authenticates with a username and password. The CLI caches the resulting token for subsequent requests.
- Client credentials — an application identity authenticates using a client ID and client secret. Configure these values on the active context using
cratis context set-value client-idandcratis context set-value client-secret.
Chronicle commands resolve authentication in this order:
- Authentication embedded in the selected connection string (credentials or
apiKey), orauth=none, takes precedence over context credentials. - When a saved login exists, its token is used only for the single TLS endpoint that issued it and with the same TLS trust settings. An expired login for that connection requires signing in again; it does not switch to stored client credentials.
- When there is no saved login, the active context’s client ID and secret are used only when both are configured and the selected connection matches the context’s transport, single host, port, and TLS trust settings.
- Otherwise, the built-in development client credentials are used only when there is no saved login and the selection matches the context’s single TLS endpoint and trust settings. For overrides to another origin and for SRV or multi-host connections, provide any required client credentials explicitly in the selected connection string.
Non-local servers will normally reject the development credentials.
auth status
Section titled “auth status”Shows the current authentication state for the active context: the logged-in user, whether client credentials are configured, or that no authentication is active. A user session includes Bound to: <server> and a warning if the stored login does not match the selected server. The selected server follows the normal flag, environment variable, context, and default resolution order.
JSON output includes tokenServer (the server bound to the login) and loginMatchesServer (true or false, or null when there is no stored login). A login matches only when its token is usable for the selected connection. SRV and multiple-host selections, disabled TLS, and explicit authentication settings do not use a saved login.
cratis chronicle auth statusExamples
Section titled “Examples”Check authentication status:
cratis chronicle auth statusGet machine-readable status:
cratis chronicle auth status -o jsonAuthenticates as a user using the resource owner password credentials flow. The CLI stores the access token and expiry in the active context (~/.cratis/config.json) for use by subsequent commands. It does not create a token file for user login. The token is bound to the server that issued it. You can log in to a different server with --server, but the active context keeps its own server setting. If the server returns no usable token or expiry, login fails without changing the context.
cratis chronicle login <USERNAME>If you omit --secret, the CLI prompts for the password interactively so it does not appear in your shell history.
Login uses the same TLS configuration as every other Chronicle command. certificatePath supplies a PKCS#12 client certificate with its private key, with or without a password; set certificatePassword when needed. It is not a PEM or DER custom trust root. With skipTlsValidation=false, the CLI accepts a valid server certificate, or a certificate with only chain errors whose hash matches the configured client certificate. A name mismatch is still rejected. With skipTlsValidation=true (the default), server certificate validation is skipped. A missing or invalid client certificate fails login without storing a session.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
USERNAME |
The username to authenticate as. |
Options
Section titled “Options”| Flag | Description |
|---|---|
--secret <PASSWORD> |
The password. Omit to be prompted interactively. |
--server <CONNECTION_STRING> |
Log in to this single, direct Chronicle server instead of the active context’s server. The stored token can be used only with this server. SRV and multiple-host login addresses are not supported. |
Examples
Section titled “Examples”Log in interactively (password prompt):
cratis chronicle login aliceLog in with password inline (use only in controlled automation):
cratis chronicle login alice --secret mysecretSubsequent Chronicle commands use the active context’s token only for the single TLS endpoint that issued it and with the same effective skipTlsValidation, caCertificatePath, and certificatePath settings. This also applies to --server overrides. If the selected connection does not match the saved login binding, commands do not use the token or fall back to other stored credentials. If the token expires, run cratis chronicle login again. Use a separate context if you need to keep a different server as the default.
After you change the context’s server, or select a different server with a flag or environment variable, non-workbench commands print a notice to stderr once per process:
Note: the stored login for alice belongs to production:35000; this command connects to staging:35000 without it. Run 'cratis chronicle login alice' to log in to this server.The notice does not require --debug and leaves JSON on stdout unchanged. Run cratis chronicle auth status to compare the bound and selected servers, then log in to the selected server if needed. The workbench keeps its own panel messaging instead of writing this notice over the terminal UI.
Use absolute paths for caCertificatePath and certificatePath. Relative paths bind the saved login to the working directory where you logged in.
Saved logins from older CLI versions lack the required TLS trust binding and are not used for authentication. Run cratis chronicle login again to save a login for the selected TLS endpoint and trust settings.
~/.cratis/config.json contains user login tokens. Client-credential access tokens are cached separately under ~/.cratis/tokens in versioned, hashed filenames. Each entry records its HTTPS OAuth token endpoint and client ID, plus a required scope hash covering the context, client ID, token endpoint, selected Chronicle origin (scheme, host and effective port), and TLS trust settings. Neither filenames nor scope keys include passwords or tokens. These hashes bind cache reuse to a destination; they do not encrypt the token or protect against a local attacker rewriting the entry.
DNS host case, the root trailing slash and equivalent IPv6 spellings are normalized; an omitted Chronicle port means 35000. For example, chronicle://HOST/ and chronicle://host:35000 share a destination. Different contexts, case-sensitive client IDs, ports or Chronicle TLS settings have separate entries, even when they use the same HTTPS OAuth endpoint. The cache is partitioned by skipTlsValidation and certificate paths. Changing the client secret does not change the cache scope. SRV and multi-host selections use only in-memory client-credential tokens because a single persisted recipient cannot be established safely.
An entry is reused only when both its endpoint/client binding and its scope hash match. Legacy context/client-only files and entries without this metadata are never reused or migrated. Creating a client-credential provider removes the old context/client-only file best-effort so unused legacy bearers do not linger; cleanup failures do not prevent authentication. The next client-credential authentication obtains a fresh token and writes a scoped replacement automatically. This path persists access tokens only: renewal reacquires them with client credentials, and no OAuth refresh token is stored or reused.
On Unix, the CLI restricts ~/.cratis to mode 0700 and its config file to 0600 when saving; the token-cache provider creates protected cache directories and files. On Windows, the token-cache provider sets protected, current-user-only ACLs on cache directories and temporary files.
login is a top-level chronicle command, not a sub-command of auth. The full command is cratis chronicle login, not cratis chronicle auth login.
logout
Section titled “logout”Clears the active context’s stored client ID, client secret, and user login token and metadata. It also removes client-credential cache files for every destination of the active context/client identity, including old-format files; cached entries for other contexts and clients are unchanged. This is a local logout, not server-side token revocation. Subsequent commands follow the credential-resolution order above, with development credentials used only when TLS is enabled and no embedded authentication or auth=none overrides the fallback.
cratis chronicle logoutExamples
Section titled “Examples”Log out of the current context:
cratis chronicle logoutlogout is a top-level chronicle command, not a sub-command of auth. The full command is cratis chronicle logout, not cratis chronicle auth logout.
Administrator-only commands
Section titled “Administrator-only commands”Managing users and applications (cratis chronicle users and cratis chronicle applications) needs a Chronicle administrator. Sign in with cratis chronicle login <administrator-username> before running them. A valid login takes precedence over client credentials stored on the context, so nothing else needs to change. When the login has expired, the CLI tells you to sign in again instead of falling back to stored client credentials.