← Back to Pull requests

feat: let a PrefectServer require an auth string #411

Closed
unknown closed this pull request without merging on Nov 24, 2026 22:20 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 00:34 UTC
Author

A PrefectServer accepted API requests from anything that could reach it, including the operator acting for a resource in another namespace. A resource can name the server in spec.server, or put its Service URL in remoteApiUrl, so checking spec.server.namespace alone can't limit which namespaces use a server.

  • PrefectServer.spec.auth names a Secret key holding username:password. The operator sets PREFECT_SERVER_API_AUTH_STRING from it, and Prefect then requires HTTP basic authentication on every request except /health and /ready, so the probes keep working.

  • spec.server.auth on the other resources names a Secret in the resource's namespace with the same string. The operator reads it like an API key Secret: the prefect.io/allowed-api-urls annotation must list the URL, and the client doesn't follow redirects.

  • A work pool's worker gets it as PREFECT_API_AUTH_STRING, which settings must not set.

  • spec.auth requires Prefect 3.6.22. For an earlier prefecthq/prefect image, the operator leaves the Deployment as it is and sets DeploymentReconciled to False with the reason UnsupportedVersion. It can't tell the version of other images, of tags such as 3-latest and 3.6-python3.12, or of an image with a digest. It deploys those, and sets the AuthSupported condition to Unknown.

  • secretKeyRef.optional must not be true, so a server doesn't start without its auth string.

  • The Secret must hold a username and a password, in ASCII, with no whitespace at either end. Otherwise the operator leaves the Deployment as it is, removes any AuthSupported condition, sets DeploymentReconciled to False with the reason InvalidAuth, and retries.

  • The server's settings must not set PREFECT_SERVER_API_AUTH_STRING when spec.auth is set, because settings override the variables the operator derives. The CRD rejects the exact name. For the name in another case, the operator sets InvalidAuth.

  • On a kubernetes work pool, flow run Jobs read the auth string from the Secret instead of holding it in their manifest. The Secret must exist in the namespace the Jobs run in, which is default in Prefect's default base job template. This requires prefect-kubernetes 0.6.3 in the worker's image. Workers of other types pass the auth string in their own way, which the guide notes.

  • The CRD rejects a reference that sets both apiKey and auth. The chart's admission policy requires get on the auth Secret, as it does for an API key Secret.
  • A new guide covers turning on auth for a running server, sharing a server across namespaces by copying the Secret, the NetworkPolicy case, and the string being sent over plain HTTP inside the cluster.

    Rollout caveats

  • no-op: servers without spec.auth behave as before.
  • <details>
    <summary>Session context</summary>

    The first plan was a spec.allowedNamespaces list on the server. A resource can put the server's Service URL in remoteApiUrl and skip that check, so authentication on the server itself replaced it. I tested auth on a kind cluster, with a server in one namespace and a kubernetes work pool in another. A flow run completed, and its Job held a secretKeyRef.

    </details>

    🤖 Generated with Claude Code

    Diff: 409 lines (+306 / -103) across 5 files Reviewer: chrisguidry Review duration: 1306m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.68) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.68 · 409 lines diff across 5 files
    0.68
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.068
    Real PR Conversation Timeline
    1 comments
    "Review active on #411"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 68% (HIGH) · Higher = larger blast radius
    68%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.4% · Safe to merge
    29.4%