Skip to content

Commit 65a2145

Browse files
andhusclaude
andauthored
Use SecretStr for API key and access token + Config follow up fixes (#112)
## Summary - **SecretStr for credentials**: `RegistryAuth.api_key` and `RegistryAuth.access_token` use Pydantic `SecretStr` — masked as `**********` in repr/logs/model_dump - **`STARDAG_API_URL`**: Replaces `STARDAG_REGISTRY_URL` as canonical env var (consistent with `STARDAG_API_KEY`, `STARDAG_API_TIMEOUT`). Old name still works with deprecation warning - **Fix: env var override + token auth**: When `STARDAG_API_URL` overrides URL/workspace/environment, user and registry_name are now inherited from the active profile so OIDC token refresh still works - Updated all docs, examples, CLI help, integration tests --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1efd46c commit 65a2145

21 files changed

Lines changed: 215 additions & 43 deletions

File tree

.claude/skills/stardag/registry-and-platform.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The SDK communicates with the API via `APIRegistry`:
4444
import stardag as sd
4545

4646
# Option 1: Environment variables
47-
# STARDAG_REGISTRY_URL=https://api.stardag.com
47+
# STARDAG_API_URL=https://api.stardag.com
4848
# STARDAG_API_KEY=sk_...
4949
# STARDAG_WORKSPACE_ID=...
5050

@@ -162,7 +162,7 @@ stardag modal stardag-api-key create # Create API key for Modal
162162
| Variable | Purpose |
163163
| ------------------------ | ------------------------- |
164164
| `STARDAG_PROFILE` | Active profile name |
165-
| `STARDAG_REGISTRY_URL` | Registry API URL |
165+
| `STARDAG_API_URL` | Registry API URL |
166166
| `STARDAG_WORKSPACE_ID` | Workspace UUID |
167167
| `STARDAG_ENVIRONMENT_ID` | Environment UUID |
168168
| `STARDAG_API_KEY` | API key (`sk_...`) |

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ For detailed SDK migration guides, see [RELEASE_NOTES.md](RELEASE_NOTES.md).
66

77
## [Unreleased]
88

9+
## [0.5.3] — 2026-04-05
10+
11+
### SDK
12+
13+
#### Security
14+
15+
- **Secret masking**: `RegistryAuth.api_key` and `RegistryAuth.access_token` now use Pydantic `SecretStr`. Values are masked as `**********` in `repr()`, `str()`, `model_dump()`, and log output, preventing accidental leakage of credentials.
16+
- **`STARDAG_API_URL` env var**: Replaces `STARDAG_REGISTRY_URL` as the canonical env var for the registry API URL. `STARDAG_REGISTRY_URL` still works as a deprecated alias with a warning. Consistent with `STARDAG_API_KEY` and `STARDAG_API_TIMEOUT`.
17+
18+
#### Bug fixes
19+
20+
- **Token auth with env var overrides**: When `STARDAG_API_URL` is set (bypassing profile for URL/workspace/environment), the loader now inherits user and registry_name from the active profile so that OIDC token auth still works.
21+
922
## [0.5.2] — 2026-04-05
1023

1124
### SDK

RELEASE_NOTES.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@ For changes to the Registry API, UI, and other components, see [CHANGELOG.md](CH
66

77
---
88

9+
## v0.5.3 — Secret masking for auth credentials
10+
11+
`RegistryAuth.api_key` and `RegistryAuth.access_token` now use Pydantic
12+
`SecretStr` instead of plain `str`. This means secrets are automatically masked
13+
as `**********` in `repr()`, `str()`, `model_dump()`, and log output.
14+
15+
**Migration**: If you read these fields directly, call `.get_secret_value()`
16+
to get the plain string:
17+
18+
```python
19+
config = get_config()
20+
if config.registry and config.registry.auth.api_key:
21+
key = config.registry.auth.api_key.get_secret_value()
22+
```
23+
24+
Truthiness checks still work (`if config.registry.auth.api_key:` is fine).
25+
26+
### Env var rename: `STARDAG_API_URL`
27+
28+
`STARDAG_REGISTRY_URL` is renamed to `STARDAG_API_URL` for consistency with
29+
`STARDAG_API_KEY` and `STARDAG_API_TIMEOUT`. The old name still works as a
30+
deprecated alias (with a `DeprecationWarning`).
31+
32+
### Bug fix: token auth with env var overrides
33+
34+
When `STARDAG_API_URL`/`STARDAG_WORKSPACE_ID`/`STARDAG_ENVIRONMENT_ID` are
35+
set directly (bypassing profile for connection details), the loader now still
36+
inherits user and registry_name from the active profile. This fixes OIDC token
37+
auth failing in setups that override the URL but rely on a profile for identity.
38+
39+
---
40+
941
## v0.5.2 — Configuration cleanup and auth token auto-refresh
1042

1143
This release restructures the configuration system and adds automatic JWT token

docs/docs/configuration/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ All CLI behavior can be overridden with environment variables:
347347
| Variable | Description |
348348
| ---------------------------- | ----------------------------- |
349349
| `STARDAG_PROFILE` | Active profile name |
350-
| `STARDAG_REGISTRY_URL` | Registry API URL |
350+
| `STARDAG_API_URL` | Registry API URL |
351351
| `STARDAG_API_KEY` | API key (bypasses OAuth) |
352352
| `STARDAG_WORKSPACE_ID` | Workspace UUID |
353353
| `STARDAG_ENVIRONMENT_ID` | Environment UUID |
@@ -436,7 +436,7 @@ All CLI behavior can be overridden with environment variables:
436436

437437
```sh
438438
# No interactive login needed - use API key
439-
export STARDAG_REGISTRY_URL=https://api.stardag.com
439+
export STARDAG_API_URL=https://api.stardag.com
440440
export STARDAG_API_KEY=sk_...
441441
export STARDAG_WORKSPACE_ID=...
442442
export STARDAG_ENVIRONMENT_ID=...

docs/docs/configuration/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Then configure:
8787
### Production (CI/CD)
8888

8989
```sh
90-
export STARDAG_REGISTRY_URL=https://api.stardag.com
90+
export STARDAG_API_URL=https://api.stardag.com
9191
export STARDAG_API_KEY=sk_...
9292
export STARDAG_WORKSPACE_ID=...
9393
export STARDAG_ENVIRONMENT_ID=...

docs/docs/configuration/profiles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Environment variables override profile settings:
175175
| Variable | Description |
176176
| ------------------------ | ---------------------------------- |
177177
| `STARDAG_PROFILE` | Active profile name |
178-
| `STARDAG_REGISTRY_URL` | Registry URL (overrides profile) |
178+
| `STARDAG_API_URL` | Registry URL (overrides profile) |
179179
| `STARDAG_API_KEY` | API key for authentication |
180180
| `STARDAG_WORKSPACE_ID` | Workspace ID (overrides profile) |
181181
| `STARDAG_ENVIRONMENT_ID` | Environment ID (overrides profile) |

docs/docs/how-to/use-api-registry.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The API Registry:
2424

2525
```sh
2626
export STARDAG_API_KEY=sk_your_api_key_here
27-
export STARDAG_REGISTRY_URL=https://api.stardag.com
27+
export STARDAG_API_URL=https://api.stardag.com
2828
export STARDAG_WORKSPACE_ID=your-workspace-id
2929
```
3030

@@ -57,7 +57,7 @@ sd.build(my_task, registry=registry)
5757
### Via Environment Variables
5858

5959
```sh
60-
export STARDAG_REGISTRY_URL=https://api.stardag.com
60+
export STARDAG_API_URL=https://api.stardag.com
6161
export STARDAG_WORKSPACE_ID=workspace-uuid
6262
export STARDAG_API_KEY=sk_...
6363
```

integration-tests/tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ def test_registry_url_from_env(
173173
self,
174174
docker_services: ServiceEndpoints,
175175
) -> None:
176-
"""Test that STARDAG_REGISTRY_URL is respected."""
176+
"""Test that STARDAG_API_URL is respected."""
177177
with tempfile.TemporaryDirectory() as tmpdir:
178178
env = {
179179
"HOME": tmpdir,
180-
"STARDAG_REGISTRY_URL": docker_services.api,
180+
"STARDAG_API_URL": docker_services.api,
181181
}
182182
result = run_stardag_cli("config", "show", env=env)
183183
assert result.returncode == 0
@@ -196,7 +196,7 @@ def test_config_with_multiple_env_vars(
196196
with tempfile.TemporaryDirectory() as tmpdir:
197197
env = {
198198
"HOME": tmpdir,
199-
"STARDAG_REGISTRY_URL": docker_services.api,
199+
"STARDAG_API_URL": docker_services.api,
200200
"STARDAG_WORKSPACE_ID": test_workspace_id,
201201
"STARDAG_ENVIRONMENT_ID": test_environment_id,
202202
}

lib/stardag-examples/src/stardag_examples/benchmarks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ STARDAG_API_KEY=<key> uv run python -m stardag_examples.benchmarks.run_benchmark
1919
# With local registry and global concurrency locks enabled
2020
STARDAG_API_KEY=<key> uv run python -m stardag_examples.benchmarks.run_benchmark --registry local --lock
2121

22-
# With remote registry (uses STARDAG_REGISTRY_URL from env/config)
22+
# With remote registry (uses STARDAG_API_URL from env/config)
2323
uv run python -m stardag_examples.benchmarks.run_benchmark --registry remote
2424
```
2525

lib/stardag-examples/src/stardag_examples/benchmarks/run_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def parse_args() -> argparse.Namespace:
292292
# Run with local registry and global locks enabled:
293293
STARDAG_API_KEY=<key> uv run python -m stardag_examples.benchmarks.run_benchmark --registry local --lock
294294
295-
# Run with remote registry (uses STARDAG_REGISTRY_URL env var):
295+
# Run with remote registry (uses STARDAG_API_URL env var):
296296
uv run python -m stardag_examples.benchmarks.run_benchmark --registry remote
297297
298298
Authentication:

0 commit comments

Comments
 (0)