Auth¶
Programmatic credential management for Docker containers. See the
Docker credentials guide for the full workflow and the
caw auth CLI.
These three functions are re-exported at the top level of caw (as auth_setup,
auth_get_status, auth_get_docker_flags) and also live in caw.auth.
setup¶
setup
¶
setup(agents: list[str] | None = None, source_home: str | None = None, dest_dir: str | Path | None = None) -> Path
Snapshot credentials and cleaned configs into an auth directory.
Host credential files are read but not modified. At container run time
they are bind-mounted into the same paths under the mount point — see
caw.auth.get_docker_flags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agents
|
list[str] | None
|
List of agent names, or None / ["all"] for all agents. |
None
|
source_home
|
str | None
|
Home directory to read credentials from. |
None
|
dest_dir
|
str | Path | None
|
Custom destination directory. Defaults to ~/.caw/auth/. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the auth directory. |
Source code in caw/auth/collector.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
get_status¶
get_status
¶
get_status(agents: list[str] | None = None, auth_dir: str | Path | None = None) -> list[AuthFileStatus]
Return structured status of all managed auth files.
Credential freshness is read from the host file directly (the source of
truth), not from the staged snapshot under auth_dir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agents
|
list[str] | None
|
Agent names to include, or None for all. |
None
|
auth_dir
|
str | Path | None
|
Custom auth directory. Defaults to ~/.caw/auth/. |
None
|
Returns:
| Type | Description |
|---|---|
list[AuthFileStatus]
|
List of AuthFileStatus for each managed file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the manifest.json doesn't exist in auth_dir. |
Source code in caw/auth/status.py
get_docker_flags¶
get_docker_flags
¶
Return the Docker -v flags for mounting the auth directory and credentials.
Emits one directory bind mount for the staging area plus one file bind mount per credential, pointing directly at the host's original file. The credentials are never copied out of their original location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth_dir
|
str | Path | None
|
Custom auth directory. Defaults to ~/.caw/auth/. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A space-separated string of Docker -v /.../.caw/auth:/tmp/caw_auth:rw -v /.../.claude/.credentials.json:/tmp/caw_auth/claude/credentials.json:rw |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the manifest.json doesn't exist in auth_dir. |
Source code in caw/auth/status.py
teardown¶
teardown
¶
Remove the auth directory. Host credential files are never touched.
Refuses to run if any host credential file is still a symlink into
auth_dir (legacy state from the old symlink-based design), since
removing the directory would leave dangling symlinks with no backup.
Pass force=True to override.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth_dir
|
str | Path | None
|
Custom auth directory. Defaults to ~/.caw/auth/. |
None
|
force
|
bool
|
Delete even if host symlinks point into |
False
|
Raises:
| Type | Description |
|---|---|
TeardownWouldOrphanSymlinksError
|
If host symlinks point into the
auth directory and |
Source code in caw/auth/__init__.py
Types¶
AuthFileStatus
dataclass
¶
AuthFileStatus(agent: str, file: str, type: str, strategy: str, exists: bool, token_expiry: str | None)
Status of a single managed auth file.