The auth command group manages credentials for OCI registries. It provides
login and logout subcommands that persist credentials locally (via the
Docker credential store or ~/.docker/config.json) and verify them against
the registry before storing.
All other regshape commands resolve credentials automatically using the
credential resolution chain (see Credential Resolution).
regshape auth login [OPTIONS] --registry <registry>
regshape auth logout [OPTIONS] --registry <registry>
| Subcommand |
Description |
login |
Authenticate against a registry and persist credentials |
logout |
Remove persisted credentials for a registry |
| Option |
Short |
Type |
Default |
Description |
--registry |
-r |
string |
required |
Registry hostname (e.g., registry.example.com) |
--username |
-u |
string |
prompt |
Username (overrides global --username) |
--password |
-p |
string |
prompt (hidden) |
Password (overrides global --password) |
--password-stdin |
|
flag |
false |
Read password from stdin instead of prompting |
--docker-config |
|
path |
none |
Alternate Docker config file path |
--time-methods |
|
flag |
false |
Print execution time for individual method calls |
--time-scenarios |
|
flag |
false |
Print execution time for multi-step workflows |
--debug-calls |
|
flag |
false |
Print request/response headers for each HTTP call |
- Resolve credentials from flags (or prompt interactively if omitted).
- Issue
GET /v2/ using a direct HTTP request with the requests library
so that the full Bearer challenge/401-retry cycle is executed automatically
(required for Docker Hub and other token-based registries).
Note: This will migrate to RegistryClient (via AuthMiddleware) once
the libs/transport/ layer is implemented.
- If the final response is
200 or 401 on retry, treat as credential failure.
- On success, persist credentials:
- If the registry has a
credHelpers entry in ~/.docker/config.json,
use dockercredstore.store().
- Otherwise, write Base64-encoded
username:password into the auths
section of ~/.docker/config.json.
| Code |
Meaning |
| 0 |
Login successful |
| 1 |
Authentication failed (wrong credentials or registry unreachable) |
# Interactive prompt for credentials
regshape auth login -r registry.example.com
# Explicit credentials
regshape auth login -r registry.example.com -u alice -p s3cr3t
# Read password from stdin (e.g., from a secrets manager)
echo "$MY_TOKEN" | regshape auth login -r registry.example.com -u alice --password-stdin
# JSON output
regshape --json auth login -r registry.example.com -u alice -p s3cr3t
# Telemetry: log scenario timing and HTTP call details
regshape auth login -r registry.example.com --time-scenarios --debug-calls
{"status": "success", "registry": "registry.example.com"}
Error: Login failed for registry.example.com: <reason>
| Option |
Short |
Type |
Default |
Description |
--registry |
-r |
string |
required |
Registry hostname |
--docker-config |
|
path |
none |
Alternate Docker config file path |
--time-methods |
|
flag |
false |
Print execution time for individual method calls |
--time-scenarios |
|
flag |
false |
Print execution time for multi-step workflows |
--debug-calls |
|
flag |
false |
Print request/response headers for each HTTP call |
- If the registry has a
credHelpers entry in ~/.docker/config.json,
call dockercredstore.erase().
- Otherwise, remove the registry's entry from the
auths section of
~/.docker/config.json.
- If no credentials are found for the registry, exit
0 with an
informational message (idempotent).
| Code |
Meaning |
| 0 |
Logout successful (or no credentials to remove) |
| 1 |
Error removing credentials |
regshape auth logout -r registry.example.com
regshape --json auth logout -r registry.example.com
Removing login credentials for registry.example.com.
or, if no stored credentials:
Not logged in to registry.example.com.
{"status": "success", "registry": "registry.example.com"}
All regshape commands (not just auth) resolve credentials using the
following priority chain implemented in libs/auth/credentials.resolve_credentials():
| Priority |
Source |
Notes |
| 1 |
--username / --password global flags |
Explicit always wins |
| 2 |
Docker credHelpers for the registry |
dockercredstore.get() |
| 3 |
~/.docker/config.json auths section |
dockerconfig.load_config() |
| 4 |
Anonymous |
username=None, password=None |
Anonymous credentials still work with registries such as Docker Hub because
AuthMiddleware completes the Bearer challenge exchange without credentials,
which those registries accept for public repositories.
| File |
Role |
src/regshape/libs/auth/credentials.py |
resolve_credentials() helper |
src/regshape/cli/auth.py |
Click auth group + login / logout commands |
src/regshape/cli/main.py |
Top-level group; registers auth group; calls resolve_credentials() |
| Scenario |
Message |
| Wrong credentials |
Error: Login failed for <registry>: authentication rejected |
| Registry unreachable |
Error: Login failed for <registry>: <connection error> |
| No cred helper found |
Falls back to docker config file silently |
| Credential store error |
Error: Could not store credentials: <reason> |