<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Darshan Patil</title>
    <description>The latest articles on DEV Community by Darshan Patil (@darshan_patil_661bbdbcacf).</description>
    <link>https://dev.to/darshan_patil_661bbdbcacf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4268101%2Fe491f621-bdcc-4a26-b440-230a3f96bdb5.png</url>
      <title>DEV Community: Darshan Patil</title>
      <link>https://dev.to/darshan_patil_661bbdbcacf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/darshan_patil_661bbdbcacf"/>
    <language>en</language>
    <item>
      <title>Improving Prefect Authentication in Datadog</title>
      <dc:creator>Darshan Patil</dc:creator>
      <pubDate>Fri, 27 Nov 2026 04:39:47 +0000</pubDate>
      <link>https://dev.to/darshan_patil_661bbdbcacf/improving-prefect-authentication-in-datadog-m1g</link>
      <guid>https://dev.to/darshan_patil_661bbdbcacf/improving-prefect-authentication-in-datadog-m1g</guid>
      <description>&lt;p&gt;I use Datadog in my day-to-day work, so I'm interested in the small integration details that make it easier to operate.&lt;/p&gt;

&lt;p&gt;One recent contribution started with a configuration mismatch: Prefect supports a combined &lt;code&gt;username:password&lt;/code&gt; credential, while Datadog's Prefect integration expected those values separately.&lt;/p&gt;

&lt;p&gt;Supporting the combined value sounded straightforward. The more interesting part turned out to be what happens to that credential after configuration is loaded—especially when someone generates a diagnostic bundle.&lt;/p&gt;

&lt;p&gt;The change is now merged in &lt;a href="https://github.com/DataDog/integrations-core/pull/25596" rel="noopener noreferrer"&gt;DataDog/integrations-core PR #25596&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The configuration mismatch
&lt;/h2&gt;

&lt;p&gt;Self-hosted Prefect supports HTTP Basic authentication. Its server can use &lt;code&gt;PREFECT_SERVER_API_AUTH_STRING&lt;/code&gt;, and clients use the matching &lt;code&gt;PREFECT_API_AUTH_STRING&lt;/code&gt; value.&lt;/p&gt;

&lt;p&gt;Both hold a combined credential, such as &lt;code&gt;username:password&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Datadog already supported authentication through separate &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt; options. The request in &lt;a href="https://github.com/DataDog/integrations-core/issues/25512" rel="noopener noreferrer"&gt;issue #25512&lt;/a&gt; was to accept the combined format too.&lt;/p&gt;

&lt;p&gt;For a deployment that already manages a combined secret, that avoids having to split it simply to configure monitoring. It doesn't add a new authentication method; it adds another way to supply the existing credentials.&lt;/p&gt;

&lt;p&gt;The final option is &lt;code&gt;prefect_userpass&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;instances&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;prefect_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://prefect.example/api&lt;/span&gt;
    &lt;span class="na"&gt;prefect_userpass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ENC[prefect_api_auth_string]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;prefect_api_auth_string&lt;/code&gt; is an illustrative secret identifier that must resolve through the Agent's configured secrets-management mechanism. &lt;code&gt;ENC[...]&lt;/code&gt; doesn't configure that mechanism by itself.&lt;/p&gt;

&lt;p&gt;The check also doesn't automatically read Prefect's environment variables. You explicitly supply the credential through Datadog configuration. Existing separate-credential configurations remain supported.&lt;/p&gt;

&lt;h2&gt;
  
  
  Split once, then use the existing HTTP client
&lt;/h2&gt;

&lt;p&gt;A password can contain a colon. Treating every colon as a separator would break a valid credential.&lt;/p&gt;

&lt;p&gt;The implementation separates the username from the remainder at the first colon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Illustrative values, not real credentials&lt;/span&gt;
&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"worker:demo:with:colons"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"worker"&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"demo:with:colons"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those values go through Datadog's existing HTTP wrapper, rather than introducing a second request path with its own authentication handling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Validation belongs with configuration
&lt;/h2&gt;

&lt;p&gt;Review feedback helped separate two kinds of validation.&lt;/p&gt;

&lt;p&gt;The credential's shape belongs in the configuration specification: a non-empty username, a separator, and a non-empty password. Datadog's tooling generates the corresponding model constraint.&lt;/p&gt;

&lt;p&gt;Rules involving multiple settings belong in &lt;code&gt;check_instance&lt;/code&gt;, after configuration defaults have been applied. For example, the combined option must not be used alongside separate &lt;code&gt;username&lt;/code&gt; or &lt;code&gt;password&lt;/code&gt; settings, or with a non-basic authentication type.&lt;/p&gt;

&lt;p&gt;That keeps request code focused on making requests. Invalid combinations fail during initialization, before a request is sent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the name changed to &lt;code&gt;prefect_userpass&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This was the part of the review that stuck with me.&lt;/p&gt;

&lt;p&gt;The setting was initially named &lt;code&gt;auth_string&lt;/code&gt;. A later suggestion was to give it a Prefect-specific name to avoid a possible future collision with a generic HTTP option.&lt;/p&gt;

&lt;p&gt;Then a maintainer pointed out another concern: the Agent's flare scrubber uses key-name rules to redact sensitive configuration values. Neither &lt;code&gt;auth_string&lt;/code&gt; nor &lt;code&gt;prefect_auth_string&lt;/code&gt; matched the relevant rules discussed in the review.&lt;/p&gt;

&lt;p&gt;Marking the option &lt;code&gt;secret: true&lt;/code&gt; in the integration specification wasn't enough to provide that runtime redaction.&lt;/p&gt;

&lt;p&gt;The final name, &lt;code&gt;prefect_userpass&lt;/code&gt;, includes &lt;code&gt;pass&lt;/code&gt;, allowing it to match the existing password scrubber rule. The reasoning is documented in &lt;a href="https://github.com/DataDog/integrations-core/pull/25596#issuecomment-6978043173" rel="noopener noreferrer"&gt;the maintainer's review comment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I found that a useful reminder: a configuration key's name can affect how other parts of the system handle its value. Parsing a secret correctly is only one part of the job. Error messages and diagnostic tooling need attention too.&lt;/p&gt;

&lt;p&gt;Secret references and HTTPS still matter; redaction isn't a replacement for either.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test what reaches the request
&lt;/h2&gt;

&lt;p&gt;The regression tests exercise the prepared HTTP request and inspect its &lt;code&gt;Authorization&lt;/code&gt; header. That checks more than whether a string was split correctly.&lt;/p&gt;

&lt;p&gt;They cover combined credentials, passwords containing colons, mixed-case basic-auth settings, existing separate credentials, and unauthenticated configuration.&lt;/p&gt;

&lt;p&gt;Invalid-configuration tests check that initialization raises a configuration error, sends no request, and doesn't include the sample secret in the error message.&lt;/p&gt;

&lt;p&gt;The HTTP transport is mocked. These tests verify request preparation and configuration behavior; they aren't a live Prefect deployment or an Agent end-to-end test. They also don't independently prove flare redaction—the naming decision follows the existing scrubber behavior identified during review.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lesson I'll take into the next integration
&lt;/h2&gt;

&lt;p&gt;This was a small feature, but it touched configuration schemas, generated models, HTTP behavior, diagnostic redaction, documentation, and tests.&lt;/p&gt;

&lt;p&gt;The review made the contribution more useful and gave me a better way to think about credentials: follow the value beyond the point where it's parsed. Check where it might appear when configuration fails or someone needs help debugging.&lt;/p&gt;

&lt;p&gt;When you review a new credential setting, do you check what ends up in the diagnostic bundle too?&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/DataDog/integrations-core/pull/25596" rel="noopener noreferrer"&gt;Merged contribution and discussion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/DataDog/integrations-core/issues/25512" rel="noopener noreferrer"&gt;Original feature request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.prefect.io/docs/v3/advanced/security-settings" rel="noopener noreferrer"&gt;Prefect self-hosted security settings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.datadoghq.com/agent/configuration/secrets-management/" rel="noopener noreferrer"&gt;Datadog Agent secrets management&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The configuration above reflects the merged change. Check that your installed Prefect integration version includes &lt;code&gt;prefect_userpass&lt;/code&gt; before using it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>datadog</category>
      <category>devops</category>
      <category>python</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
