Authentication
The CLI authenticates through your browser using the same identity as the dashboard. There is no separate password and no API key to paste.
Signing in
secureai loginWhat happens:
- The CLI starts a temporary listener on
127.0.0.1on a random high port and generates a PKCE verifier and challenge. - Your browser opens to the control plane's authorisation page.
- You sign in as you normally would. Your organisation configures the identity provider, which handles the credentials.
- The browser redirects back to the loopback listener with a one-time code. The CLI exchanges it, with the PKCE verifier, for a session token.
- The session is written to
~/.secureai/credentials.jsonand the listener shuts down.
Why loopback and PKCE
The token never travels through a copy-paste step and never appears in your shell history or process list. The authorisation code is bound to a secret the CLI generated locally, so an intercepted code is useless on its own.
If the browser cannot open
On a headless machine the CLI prints the URL instead. Open it on any device, complete the sign-in, and the loopback callback still has to reach the machine running the CLI. So for remote servers, forward the port over SSH:
ssh -L 54123:127.0.0.1:54123 user@remote-hostChecking who you are
$ secureai whoami
you@yourcompany.com
Name Your Name
Role developer
Server https://api.corelayersecurity.comYour role comes from the control plane, not from anything local. Changing the file will not grant you more access. It determines which commands you can run and which payloads you can fetch.
Signing out
secureai logoutThis clears the stored credentials on this machine. For a session you no longer control, such as one on a lost laptop or former colleague's device, an org admin revokes it from CLI access in the dashboard.
Choosing the server
| Source | Example | Precedence |
|---|---|---|
--server | --server https://api.corelayersecurity.com | Highest |
SECUREAI_SERVER | export SECUREAI_SERVER=https://api.corelayersecurity.com | Used when the flag is absent |
| Default | http://localhost:8080 | Fallback |
What your role allows
Four roles exist in every organisation. The CLI enforces the same boundaries as the dashboard. For example, the adversarial payload corpus is available only to developers and security researchers.
| Role | CLI access |
|---|---|
| Organisation Admin | Full CLI access; also manages users, models, and CLI tokens in the dashboard. |
| Security Researcher | Full CLI access across all four phases. |
| Developer | Full CLI access, scoped to the models and projects they are assigned. |
| Executive | No CLI use in practice. This role is dashboard-only, for posture and compliance summaries. |
The complete permission matrix is on Roles & permissions.
Authenticating in CI
Browser login is interactive and will not work on a build runner. Instead, an org admin issues a scoped CLI token from the dashboard and you expose it to the job as a secret.
- name: Scan prompts
env:
SECUREAI_SERVER: https://api.corelayersecurity.com
SECUREAI_TOKEN: ${{ secrets.SECUREAI_TOKEN }}
run: secureai scan ./prompts --fail-on highTreat CLI tokens like deploy keys
A token carries the user, project, model, and environment scope it was issued with. Store it in your CI secret store, never in the repository, and rotate it from CLI access when someone leaves the team.
Troubleshooting
- “not logged in: run `secureai login`”: no credentials file, or it was removed. Log in again.
- “state mismatch on callback”: the browser returned a response from a different login attempt. Close stray tabs and retry.
- The browser hangs on the callback: something else holds the loopback port, or a VPN is intercepting
127.0.0.1. Retry; the CLI picks a new port each time. - 401 on a command that worked yesterday: your session expired or was revoked. Run
secureai loginagain.