Tenant Asset Changes: 5 Checks for Vanity CNAME and Signed URLs
Publish a tenant's vanity CNAME only when its target matches the intended asset host; issue signed URLs for that tenant's verified hostname, and use the default hostname until verification succeeds. Keep routing and authorization separate. A successful DNS change is not evidence that a private course file is protected. TL;DR: Store the hostname per tenant, reconcile intended records against…
5 Steps for Vanity CNAME and Signed URLs
When setting a tenant's vanity CNAME, ensure its target aligns with the desired asset host. Generate signed URLs for the tenant's validated hostname, utilizing the default hostname until verification is confirmed. Maintain routing and authorization as separate components. Remember, a DNS change alone doesn't guarantee private course file protection. Here's how to proceed:
1. Verify the vanity asset hostname and CNAME by compiling a change manifest. This should include the tenant identifier, stored vanity hostname, intended asset host, default asset hostname, and the verification outcome. Keep the mail provider's MX configuration separate from this manifest. An example tenant, North School, has an asset hostname of assets.north.example and aims to CNAME it to assets.platform.example.
These are placeholders, not real endpoints. The three checks are: stored hostname belonging to the tenant's configuration, CNAME matching the intended asset host, and verification of the vanity record. A successful initial check doesn't confirm the others. Ensure the verified record is attached to the configuration in question, especially if the hostname changes during verification.
2. Reconcile the CNAME without linking it to access. Update the customer's CNAME to the intended asset host. Design the reconciliation job to be repeatable, so the same desired configuration applied twice yields the same record, not multiple changes. Keep enough application state to differentiate a retry of the same intent from a new cutover request. An idempotency key can help prevent duplicate writes, but it can't determine the current desired configuration. Preserve a previous known configuration for rollback purposes.
3. Choose the tenant's hostname before creating signed links. Use the tenant's verified vanity hostname if it's valid for the intended configuration; otherwise, use the default hostname. Generate the signed URL against this selected hostname. Don't rely on a tenant's display name to determine the hostname. Before implementing the write adapter, check the service's discovery response to confirm support for DNS upserts and storage presigning.
You can find this information without guessing request fields or needing an API key. Use the public discovery interface in your Go example and authenticate with the same environment variable used by the backend adapter. This step retrieves the needed capabilities without performing a DNS write or asset download.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to