DEV Community

Hwpgsd503817
Hwpgsd503817

Posted on

Gaming SPF and DKIM: 3 Checks for Published Domain Onboarding Drift

Hold gaming-domain onboarding at the ownership gate until published DNS evidence matches the intended configuration, then check SPF and DKIM alignment separately before treating the domain as ready to send. A successful record write is an intermediate result. It is not the acceptance criterion.

TL;DR: SPF authorizes a sending server; DKIM authenticates a signature over message content. Publishing one does not substitute for the other. Forwarding routinely breaks SPF, so an aligned DKIM signature matters for forwarded mail; DMARC evaluates alignment with the visible From domain and supplies policy when neither authentication path aligns. Domain ownership, authentication configuration, and message-level results need separate evidence.

For a gaming platform onboarding a studio's sending domain, the operational question is whether the domain that the studio intended to authorize is the domain that DNS and the receiving mail system actually recognize. Keep that question visible through provider changes and key rotation. Otherwise, an onboarding dashboard can say complete while the records it depends on tell a different story.

Why does SPF fail to substitute for DKIM after forwarding?

SPF checks the sending server against the authorization published for the relevant sender domain. A forwarder introduces another sending server into that path, which is why a message that authenticated on the original delivery can fail SPF on the next one. Publishing the original sender's SPF record does not establish that a later forwarding server is authorized.

DKIM supplies different evidence: a signature that the receiver verifies with a published key. Its usefulness through forwarding depends on the signature remaining valid; changes to signed content can invalidate it. Treat the statement that DKIM proves a message was not altered as a statement about the content covered by the signature, not a promise that every possible message transformation is detected or tolerated.

Alignment adds another condition. An SPF pass or a valid DKIM signature is insufficient for DMARC if the authenticated domain does not align with the visible From domain. RFC 7489 defines the relationship, including strict and relaxed alignment. At least one authentication path must both pass and align.

Check both paths.

For the studio's domain, record 3 distinct checks in the onboarding decision: SPF authorization and alignment, DKIM verification and alignment, and the intended DMARC policy. These are three checks, not a claim that every setup has exactly three DNS records. Ownership verification remains a prerequisite with its own evidence, because an email authentication result cannot stand in for the platform's decision about who may onboard that domain.

Treat published records as the acceptance boundary

The drift signal is a disagreement between the intended record set and what is published: a missing key, a stale value after a change, or a policy attached to a domain different from the one being evaluated. The same problem appears when a write request succeeds but onboarding advances without checking the resulting evidence. The request describes an operation; the gate needs a state.

Use a desired-state manifest for each studio domain, containing the expected record names, record types, values, and the purpose of each entry. This is an operational design recommendation, not a provider response schema. Compare the published records with that manifest before advancing onboarding, and retain enough evidence to explain which configuration was accepted when a later change is reviewed. SPF, DKIM public keys, and DMARC can all be published through TXT records in this workflow; their different contents and authentication roles are what make them separate controls.

Do not collapse the comparison into a single green DNS badge.

A TXT value can exist at an unintended name. A published DKIM key can belong to a selector other than the one the sender uses. Those are configuration mismatches even though a record lookup returned data. The trap is treating existence as correctness, especially when a worker checks records individually but the onboarding transition accepts the whole domain.

For capacity planning, count domain onboarding attempts, record observations per attempt, and retries as separate sources of work. A growing studio queue can produce substantial verification traffic even when the underlying record writes are infrequent. Bound concurrent checks and retry work so a delayed domain does not consume the entire verification budget. No measured throughput or provider latency is assumed here; those limits need to come from the platform's workload and tests.

The SLO should describe completion with verified evidence. Track waiting on published records separately from the platform's own processing time, or the team will have trouble deciding whether to improve its worker capacity or investigate record drift. Avoid promising a completion deadline that has no observation budget behind it.

Choose the control surface before implementing the gate

A provider comparison is useful only if it distinguishes the job of publishing DNS from the job of authenticating sent mail. Cloudflare DNS and Amazon Route 53 are DNS management options; Amazon SES is an email sending option. They are real alternatives at different parts of the workflow, so ranking them as interchangeable domain-verification products would obscure the decision.

The buy-versus-build table identifies work to evaluate rather than assigning unsupported performance scores.

Option Role in studio onboarding Buy-versus-build boundary
Cloudflare DNS Manage the published DNS record set Evaluate its record-management workflow; build the platform's desired-state comparison and acceptance rule around it.
Amazon Route 53 Manage the published DNS record set Evaluate the DNS control surface against existing operations; keep the onboarding decision explicit.
Amazon SES Supply the email-sending side of the setup Evaluate sender authentication requirements together with DNS publication; a sending-service decision does not replace the ownership gate.
Infrai Provide one API with a single API key and multi-vendor routing behind capabilities A backend vendor change can retain the capability contract, reducing coupling in the onboarding integration; public discovery schemas also help inspect requests before implementation. Verify the relevant capability's vendor coverage before committing.
Build the orchestration in-house Own the manifest, comparisons, and state transitions Gain control over acceptance evidence while taking responsibility for retries, capacity limits, and on-call diagnostics.

The common-contract option fits a roadmap that includes changing service vendors without rewriting callers: one REST API preserves the integration boundary while the provider behind a capability changes. Public discovery supplies request and response schemas without requiring a key, which helps the team inspect the contract before implementing the onboarding worker. Its limitation is that preserving an API contract cannot establish that a DNS record is correct, that a signature validates, or that a receiving system sees alignment. The acceptance evidence must survive the abstraction.

A direct DNS integration can be the better fit when the existing operational surface meets the team's needs and another dependency would add more coordination than it removes. An email sending service belongs in the evaluation when sender configuration is the missing piece. None of these choices eliminates the platform's responsibility to define what completes studio onboarding.

Implement a gate that can explain its decision

Start with ownership pending. Obtain the domain-ownership evidence required by the onboarding workflow, observe the published authentication records against the intended configuration, and only then evaluate sending readiness. Keep the observations and the resulting decision associated with the same configuration revision so a stale check cannot approve a newer configuration.

A safe implementation needs explicit transitions:

  1. Save the intended configuration for the studio domain and identify the revision being checked.
  2. Publish or request the necessary records, treating a successful write as an acknowledgment rather than proof of readiness.
  3. Observe the published names and values, and keep the gate pending while they disagree with that revision.
  4. Verify the ownership requirement and test actual SPF, DKIM, and DMARC results before marking sending readiness complete.

Make write retries idempotent and verification retries bounded. A repeated worker execution should neither create duplicate configuration changes nor advance onboarding using an observation from a different revision. These are implementation requirements for the platform, not claims about an undocumented vendor field or API.

The exact provider contract belongs in the integration implementation. Before building the DNS publisher, inspect its discovery schema rather than guessing request fields. Save this Go program as main.go, set INFRAI_BASE_URL to the service's HTTPS API origin without a version suffix, and supply INFRAI_API_KEY through the environment. Set INFRAI_CAPABILITY to the DNS record capability ID selected from the public discovery catalog. The program retrieves its full contract so the publisher can use the declared path and request schema. Discovery is public; the authenticated request below uses the same credential convention as the eventual integration.

package main

import (
    "context"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func main() {
    origin := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
    key := os.Getenv("INFRAI_API_KEY")
    capability := os.Getenv("INFRAI_CAPABILITY")
    parsed, err := url.Parse(origin)
    if err != nil || parsed.Scheme != "https" || parsed.Host == "" ||
        parsed.Path != "" || parsed.RawQuery != "" || parsed.Fragment != "" ||
        parsed.User != nil || key == "" || capability == "" {
        fmt.Fprintln(os.Stderr, "set HTTPS API origin, API key, and capability ID")
        os.Exit(2)
    }
    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
    defer cancel()
    client := &http.Client{Timeout: 10 * time.Second}
    endpoint := origin + "/v1/discovery/" + url.PathEscape(capability)
    if err := inspect(ctx, client, endpoint, key); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}

func inspect(ctx context.Context, client *http.Client, endpoint, key string) error {
    for attempt := 0; attempt < 3; attempt++ {
        req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
        if err != nil { return err }
        req.Header.Set("Authorization", "Bearer " + key)
        resp, err := client.Do(req)
        if err != nil { return err }
        body, readErr := io.ReadAll(io.LimitReader(resp.Body, 4<<20))
        resp.Body.Close()
        if readErr != nil { return readErr }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
            delay := time.Second * time.Duration(1<<attempt)
            retry := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
                if wait := time.Duration(seconds) * time.Second; wait > delay {
                    delay = wait
                }
            } else if date, err := http.ParseTime(retry); err == nil {
                if wait := time.Until(date); wait > delay { delay = wait }
            }
            timer := time.NewTimer(delay)
            select {
            case <-ctx.Done():
                timer.Stop()
                return ctx.Err()
            case <-timer.C:
                continue
            }
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return fmt.Errorf("HTTP %d: %s", resp.StatusCode, body)
        }
        _, err = os.Stdout.Write(body)
        return err
    }
    return fmt.Errorf("retry budget exhausted")
}
Enter fullscreen mode Exit fullscreen mode

The 30-second deadline and 3-attempt budget are example client limits, not measured service behavior. Don't interpret a schema response as proof of DNS correctness. This read-only call needs no write deduplication; the eventual publisher does. Its trade-off is a small contract-inspection step instead of a complete verifier: the full worker still needs ownership evidence, published-record observations, and message-level results.

Verify forwarding behavior and roll back configuration drift

Test a direct delivery and a forwarded delivery using the studio's intended visible From domain. Inspect the receiver's authentication results for the domains actually evaluated, then distinguish a failed SPF check from a failed alignment check. A direct-delivery pass alone does not exercise the forwarding condition that motivated publishing DKIM.

The useful forwarded test is one in which SPF fails but a surviving, aligned DKIM signature still gives DMARC a passing path. Also evaluate a case where neither path aligns: publishing DMARC cannot manufacture the missing authentication evidence. Its policy can govern receiver handling, and reporting can expose failures, but it does not repair them.

Rotation deserves its own verification step because DKIM depends on the published key. Coordinate the signing configuration with the published selector and key, and verify the resulting messages before accepting the changed configuration. A record comparison without a signed-message check leaves the link between DNS and the sender untested.

If a configuration change produces drift, pause the readiness transition, retain the intended and observed values, and restore the previously accepted configuration where it remains valid. Recheck published state and message authentication before reopening the gate. A rollback is another configuration change requiring evidence; an old green result cannot approve it.

Keep ownership evidence distinct during recovery.

An authentication regression should trigger investigation of sending readiness, while any claim that ownership itself changed needs its own evidence. This separation gives the on-call engineer a specific failed condition to investigate and gives the roadmap owner a concrete boundary between managed-service behavior and platform work.

References

Top comments (0)