Chris Killpack
09/12/2025, 7:04 PM[server.api]
auth_string="foo:bar"
How can I configure the worker with the same basic auth? I prefer to specify via a file over environment variables.Marvin
09/12/2025, 7:04 PMNate
09/12/2025, 7:06 PMprefect.toml wherever you do prefect worker start
otherwise people commonly like to use prefect config set PREFECT_{something}={value} to set settings for a whole profile (applied whenever using the CLI/SDK and that profile is active)Marvin
09/12/2025, 7:11 PMPREFECT_API_AUTH_STRING setting (format: user:pass). You can do this purely via files in two common ways:
Option A — Profiles (global, file-backed)
- This writes to ~/.prefect/profiles.toml (no env vars needed):
prefect profile create local-auth
prefect --profile local-auth config set PREFECT_API_URL="<http://127.0.0.1:4200/api>" PREFECT_API_AUTH_STRING="foo:bar"
prefect profile use local-auth
prefect worker start -p <your-pool>
- Or edit the file directly:
# ~/.prefect/profiles.toml
[profiles]
active = "local-auth"
[profiles.local-auth]
PREFECT_API_URL = "<http://127.0.0.1:4200/api>"
PREFECT_API_AUTH_STRING = "foo:bar"
Then start your worker with that profile active:
prefect --profile local-auth worker start -p <your-pool>
Option B — Project-level TOML file
- In a prefect.toml at your project root:
[prefect.api]
url = "<http://127.0.0.1:4200/api>"
auth_string = "foo:bar"
- Or in `pyproject.toml`:
[tool.prefect.api]
url = "<http://127.0.0.1:4200/api>"
auth_string = "foo:bar"
Start the worker from that directory (or ensure the file is present in the worker’s filesystem).
Notes:
- If both PREFECT_API_KEY and PREFECT_API_AUTH_STRING are set, the API key takes precedence.
- For containerized workers, bake ~/.prefect/profiles.toml into the image or mount it, or include a `prefect.toml`/`pyproject.toml` in the working directory.
Docs for reference:
- Security settings (basic auth)
- Settings and profilesBring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by