Velocity • Durability

Version 12.0.0

3. Authentication and Sessions

This chapter covers the following topics.

3.1 Authentication Modes

PanCTL supports two distinct ways of authenticating:

Mode How it works Best for
Profile session panctl auth login exchanges your username/password for an access token and refresh token, which are stored locally in a named profile. Later commands reuse this session automatically and renew it silently when it expires. Interactive, day-to-day administration
Pre-issued API token A long-lived token (created with auth tokens create or service-accounts tokens create) is passed directly via --token, --token-stdin, or the PANCTL_API_TOKEN environment variable. No profile is read or written. Scripts, CI/CD, automation, service accounts

3.2 Logging In (auth login)

panctl auth login [server] [--server <addr>] [--username <user>] [--password-stdin] [--insecure] [--profile <name>]

Interactive example:

$ panctl auth login
Profile [default]:
Server [realm_dns_name]: 34.63.175.103
Username: finch/alice
Password:
Login succeeded

Usernames are tenant-qualified: <tenant-name>/<username> (e.g. finch/alice). A bare name such as admin logs in to the platform tenant. There is no separate --tenant flag on login; the tenant is always part of the username.

Server address resolution (first match wins): A positional argument or --server → the PANCTL_API_SERVER environment variable → the value already stored in the target profile → http://localhost:8000. A bare host/IP is filled in with http:// and port 8000 if you don’t specify them:

panctl auth login 34.63.175.103                     # -> http://34.63.175.103:8000
panctl auth login --server 34.63.175.103:9000        # explicit port is kept
panctl auth login --server https://api.example.com   # explicit https keeps port 443

PanWeb also reverse-proxies the API on port 443, so panctl auth login https://34.63.175.103:443 --insecure reaches the same paths as port 8000 does directly. Write the https:// form out in full because nothing is filled in for it, and --insecure stays a deliberate choice since it persists to the profile.

Choosing where the password comes from. There are four sources, and each exposes the password differently:

Source What it exposes
--password <value> The OS process listing and your shell history
--password-stdin Nothing; the recommended path for scripts
PANCTL_PASSWORD The process environment, CI logs, and shell configuration
The hidden prompt Nothing, but it needs a terminal

The first one supplied wins, in the order shown, and it skips the prompt. --password and --password-stdin are two spellings of one secret, so passing both is refused before anything is sent.

printf '%s' "$PASSWORD" | panctl auth login 34.63.175.103 --username finch/alice --password-stdin

A successful login prints Login succeeded to standard error and nothing to standard output.

As its last step, after it reports success, login downloads the API’s OpenAPI specification (see 1.2) and caches it. If that download fails, the login still succeeds, a warning: line appears on standard error, and the exit status stays 0. Commands then run without local request validation until the next successful login.

Other login flags:

Flag Purpose
--profile <name> Log in under a named profile instead of the default. On login specifically, a successful attempt also switches your active profile to this one.
--insecure Skip TLS certificate verification for this login and all future commands run under this profile. An explicit --insecure or --insecure=false on the command line wins over the PANCTL_API_INSECURE environment variable, which in turn wins over the setting already saved in the profile.
--server <addr> The server address, as an alternative to the positional [server] argument (see the address resolution rules above).
--username <user> The tenant-qualified username to log in as (for example finch/alice).
--password <value> The password on the command line. It is visible in the process listing and your shell history, so prefer --password-stdin or the prompt. It cannot be combined with --password-stdin.
--password-stdin Read the password from standard input (see the example above).

3.3 Checking Your Identity (auth whoami)

$ panctl auth whoami
PROFILE:            lab
SERVER:             http://10.97.5.200:8000
USER ID:            u-1
TENANT ID:          t-1
IS PLATFORM ADMIN:  false

The lines after PROFILE and SERVER are the API’s own answer, so the exact fields can vary and include the roles and permissions of the identity. With a pre-issued token the first line reads auth: <source> (for example env:PANCTL_API_TOKEN) in place of the profile because no profile was consulted. Under --as-tenant-admin (see 5.1) it reports the delegated identity; is_delegated is true, user_id is the platform-support principal, and actor_user_id names you.

Useful for confirming which server and account a profile is pointing at before you run something destructive.

3.4 Logging Out (auth logout)

panctl auth logout                  # clears the active profile's session
panctl auth logout --profile lab    # clears a specific profile

This removes the stored session locally (server, tokens, TLS setting); there is no server-side “logout” call, since the tokens simply expire on their own if left unused.

3.5 API Tokens (auth tokens)

Long-lived tokens you can hand to scripts or CI systems instead of a username/password.

Command Purpose
auth tokens create --name <label> --expires-in-days <n> [--description <text>] Create a new token (accepted lifetimes: 30, 90, 180, 365 days)
auth tokens list [--active-only] List your tokens
auth tokens get <token_id> Show details of one token
auth tokens revoke <token_id> [--reason "<text>"] Immediately invalidate a token (asks for confirmation)
panctl auth tokens create --name ci-runner --expires-in-days 90
panctl auth tokens list --active-only
panctl auth tokens revoke jusKjSv7iJzMmaL9 --reason "rotated"

# Capture just the secret for use in a script:
TOKEN=$(panctl auth tokens create --name ci-runner --expires-in-days 90 --format 'jsonpath={.token}')

Important: the token secret is only ever shown once, at creation time. Store it somewhere safe immediately.

3.6 Using a Pre-Issued Token

export PANCTL_API_TOKEN=vdt1_...
export PANCTL_API_SERVER=10.97.26.200
panctl volumes list

or per-command:

panctl volumes list --token-stdin < token.txt

In this mode, PANCTL_API_SERVER is required (there’s no profile to fall back on), and nothing is written to disk. A rejected token produces a clear error and a distinct exit code (3), which is useful for detecting expired automation credentials in scripts.

auth login and auth logout refuse the token flags and ignore the environment token because they exist to change the profile session. An exported CI variable therefore does not interfere with a login.

3.7 Automatic Session Renewal

You generally never need to think about this. PanCTL renews a profile’s session automatically, either just before it’s known to have expired or transparently after a single authentication failure, and retries the original command once. By default an access token lasts 60 minutes and a refresh token lasts 7 days, and each renewal issues a new pair. A profile that goes unused for more than 7 days therefore needs a new login. If renewal itself fails, you’ll see:

error: session expired. Run: panctl auth login --profile <name>