DEV Community

SolaceW31
SolaceW31

Posted on

Python School Enrollment: 3 Checks Bind Domain TXT Proof to Workspace Access

Give a school automatic workspace enrollment only while its current domain claim, published TXT proof, and admission policy agree. Provisioning a tenant subdomain should never silently enable membership for everyone with a matching email suffix.

Short answer: use a tenant-bound TXT challenge to establish a domain claim, then make auto-join versus manual approval a separate authorization decision. For an edtech service that automatically assigns each tenant a subdomain, reconcile intended claims against observed records before admitting a new member. If that evidence is missing, stale, or disputed, hold enrollment for review.

Publication isn't permission.

The useful distinction appears in email authentication too. RFC 7489 describes publishing DMARC policy in DNS TXT records and evaluating authenticated identifiers against an author domain. It does not define workspace enrollment or make a matching email address a membership entitlement. That boundary matters when a school uses the same domain for students, teachers, and administrative staff: a domain-wide rule is a broad admission policy, even if the DNS proof is valid.

Decision: treat enrollment as reconciliation

This design uses a desired-state record for each school claim. An illustrative tenant, cedar, receives cedar.learning.example; its separately claimed email domain is cedar-school.example. Those names serve different purposes. Creating the service-controlled tenant hostname establishes where the workspace lives. Proving control of the school's domain establishes evidence for an admission rule. Neither action should imply the other succeeded.

The decision axis is drift between that desired state and the published proof. A completed provisioning job is insufficient evidence: it records an action the application intended to take, while enrollment needs an observation tied to the current claim. Store a claim revision, the tenant identifier, the exact claimed domain, the expected challenge, and the observation time. Keep the challenge purpose specific to workspace admission so that an email-policy record cannot accidentally satisfy it. These are application design choices, not a verification protocol specified by DMARC.

There are 3 checks in the proposed admission path: the claim still belongs to this tenant and revision; its current TXT observation matches the expected challenge; and the applicant satisfies the tenant's admission policy. Auto-join requires all three. Manual approval addresses the third check when a school needs a human decision; it must not quietly replace missing evidence for the first two.

Use exact boundaries.

For this design, claiming cedar-school.example does not automatically authorize claims for other domains or tenant namespaces. Nor does it establish that every mailbox represents an eligible student. Treat subdomain scope and role eligibility as explicit policy inputs. If two tenants claim the same domain, hold admission until the ownership assignment is resolved. A human approval screen should display that conflict rather than turning the newest request into the winner.

Should domain TXT proof grant automatic workspace access?

Only what the application binds to it. The proposed challenge proves that the expected value was observed at the designated DNS name for a particular claim revision. It does not by itself prove a person's identity, school affiliation, or permission to administer a workspace. A separate mailbox-verification step can establish possession of an address; the school's policy must still decide whether that address is sufficient for enrollment.

This is where a deliverability concern becomes an access-control concern. An unanswered verification email should leave the applicant pending. It should not trigger a fallback that grants access from the address suffix alone. Likewise, a retry of that message should not create another membership. Keep message delivery, mailbox evidence, and membership decisions as separate states, with a repeatable admission operation that yields the same result for the same applicant and claim revision.

RFC 7489 provides a useful warning about overreading DNS evidence. Its policy-discovery mechanism concerns DMARC records, and its identifier-alignment rules concern authenticated email identifiers. Reusing the existence of a DMARC record as a school's workspace ownership token would collapse two unrelated purposes. Keep the records separate. A published mail policy is evidence about mail policy.

For the school, the operational choice looks like this:

Admission policy Additional decision after domain proof Drift response Appropriate use
Automatic enrollment Verified mailbox and explicit domain-wide eligibility Hold new admissions until evidence agrees A school deliberately admits all eligible addresses in the claimed scope
Manual approval An authorized reviewer confirms individual eligibility Keep requests pending; show the claim conflict Shared school domains with different student and staff permissions
Explicit invitations An invitation binds an applicant to a tenant and role Evaluate the invitation under its own policy Small cohorts whose membership cannot be inferred from a domain

This table compares proposed policies, not delivery guarantees. Automatic enrollment removes a review step but broadens the consequence of an incorrect domain rule. The trade-off is explicit: less review work means relying more heavily on the school's domain-wide eligibility rule. This approach is not suitable for schools that need individual roster checks before every admission; use explicit invitations or manual approval there. Manual approval adds queue ownership and response-time work. Invitations require maintaining a roster or equivalent eligibility source. None makes an unresolved claim safe to ignore.

The critical path binds evidence to a revision

The following Python example models only the admission decision. DNS observation and mailbox verification are inputs supplied by separate components. The observation_current flag represents an application-defined freshness rule; it is not a DNS feature or a universal time limit.

from dataclasses import dataclass
from typing import Literal


@dataclass(frozen=True)
class Claim:
    tenant: str
    domain: str
    revision: int
    expected_txt: str
    mode: Literal["auto", "manual"]


@dataclass(frozen=True)
class Evidence:
    tenant: str
    domain: str
    revision: int
    txt_values: frozenset[str]
    observation_current: bool
    claim_conflict: bool
    mailbox_domain: str
    mailbox_verified: bool
    eligible: bool
    reviewer_approved: bool


def decide(claim: Claim, evidence: Evidence) -> str:
    claim_matches = (
        evidence.tenant == claim.tenant
        and evidence.domain == claim.domain
        and evidence.revision == claim.revision
    )
    if not claim_matches or evidence.claim_conflict:
        return "hold_claim"
    if not evidence.observation_current:
        return "hold_observation"
    if claim.expected_txt not in evidence.txt_values:
        return "hold_proof"
    if not evidence.mailbox_verified:
        return "hold_mailbox"
    if evidence.mailbox_domain != claim.domain:
        return "hold_scope"
    if not evidence.eligible:
        return "hold_eligibility"
    if claim.mode == "manual" and not evidence.reviewer_approved:
        return "pending_approval"
    return "admit"
Enter fullscreen mode Exit fullscreen mode

Here, the domain strings are canonical values produced by an upstream domain-validation component, and txt_values contains complete observed values after DNS parsing. The function does not implement either parser. The reviewer approval must also refer to this applicant, tenant, and revision before being passed in; an unscoped approval boolean stored on the account would defeat the boundary.

The final membership write needs the same discipline. Recheck that the claim revision is unchanged when committing admission, and make the membership operation idempotent. Otherwise, a worker can evaluate revision 4, wait while an administrator changes the claim to revision 5, and then grant access using the earlier result. Those revision numbers are an illustrative race, not production measurements. Prevent it with a conditional commit tied to the evaluated revision; on a mismatch, evaluate again.

Operate the gap between intent and observation

Choose and document how old an observation may be for a new admission. A tighter window increases verification work and can leave more applicants waiting; a looser window accepts a longer period in which evidence may no longer reflect the intended claim. There is no universal freshness threshold in the cited DMARC specification for this workspace design. The school service must choose one according to the consequence of a mistaken enrollment.

Expose the reason for a hold. An administrator should be able to distinguish an unobserved TXT value, an expired observation, a conflicting tenant claim, and an applicant awaiting approval without reading worker logs. Record the claim revision and decision reason with the admission event. Keep verification tokens and unnecessary mailbox details out of general logs, and define retention and reviewer access for the evidence that is retained. That supports an audit without treating every operational record as a permanent student directory.

Test the transitions that can change a decision: a matching observation from an older revision, the correct token attached to another tenant, a verified mailbox outside the claimed scope, approval arriving after a policy change, and a repeated admission request. Include a case where the subdomain is provisioned successfully but domain proof is still pending. The expected outcome is a usable provisioning status with enrollment held, rather than one ambiguous “ready” flag for the entire workflow.

Deploy policy changes with admission effects visible. A move from manual review to automatic enrollment changes who can enter; it deserves a preview of affected pending applicants. Track the age of unresolved claims and approval queues alongside the count of new memberships. A low error count says little if students remain stuck waiting for evidence that nobody owns the work to reconcile.

Rejected option: let the email suffix decide

The rejected shortcut grants membership when an email suffix matches a domain marked verified at some earlier point. It loses the connection between the current claim and the evidence used for today's decision. It also treats domain affiliation as an eligibility policy without requiring the school to choose that policy explicitly.

A suffix match still has a valid, narrower use: suggest the likely workspace before authentication, subject to the service's information-disclosure policy. The suggestion should not grant membership or a privileged role.

For automatic school subdomains, keep the enrollment boundary explicit: reconcile the claim, observe its proof, and apply the chosen admission policy. Use manual approval where individual eligibility needs judgment. Hold new access when the evidence disagrees, and give the responsible administrator a concrete reason to resolve it.

References

  • RFC 7489, especially Sections 3.1, 6.1, and 6.6.3: identifier alignment, DNS TXT policy publication, and policy discovery. This specification covers email authentication policy; the workspace admission design above is an application proposal. https://datatracker.ietf.org/doc/html/rfc7489

Top comments (0)