Skip to content

custom domains: auth#2908

Draft
Soxasora wants to merge 191 commits intostackernews:masterfrom
Soxasora:feat/custom-domains-auth
Draft

custom domains: auth#2908
Soxasora wants to merge 191 commits intostackernews:masterfrom
Soxasora:feat/custom-domains-auth

Conversation

@Soxasora
Copy link
Copy Markdown
Member

@Soxasora Soxasora commented Apr 8, 2026

Description

Part of #1942, revives and adapts #2180
Focuses on synchronizing authentication between SN and a custom domain.
It features a new sync endpoint that checks if there's a session and if so, redirects to the custom domain with a verification token that gets exchanged with a session token via POST.

Media

Auth Sync Login

Screen.Recording.2025-05-25.at.21.39.07.mp4

Additional Context

TODOs:

  • pick an SN account to synchronize
  • protect from open redirects
    • api/auth/sync
    • api/auth/redirect -> to be moved into api/redirect for general purpose workaround

Checklist

Are your changes backwards compatible? Please answer below:
Yes, only engages on custom domains

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
6, Q/A OK, edge cases handled correctly

For frontend changes: Tested on mobile, light and dark mode? Please answer below:
n/a

Did you introduce any new environment variables? If so, call them out explicitly here:
n/a

Soxasora and others added 30 commits May 1, 2025 18:38
- ACM support
- custom domains crud, resolvers, fragments
- custom domains form, guidelines
- custom domains context
- domain verification every 5 minutes via pgboss
- domain validation schema
- basic custom domains middleware, to be completed
- TODOs tracings
- CustomDomain -> Domain
- DomainVerification table
- CNAME, TXT, SSL verification types
- WIP DomainVerification upsert
…ange status of a Record from its Attempt, multi-purpose dns verification
- use DomainVerificationStatus enum for domains and records
- adapt Territory Form UI to new schema
- return 'records' as an object with its types
- wip: prepare for attempts and certificate usage for prisma
fix:
- fix setDomain mutation transaction
- fix schema typedefs

enhance:
- DNS records guidelines with flex-wrap for longer records

cleanup:
- add comments to worker
- remove console.log on validation values
… HOLD

handle territory changes via triggers
- on territory stop, HOLD the domain
- on territory takeover from another user, delete the domain and its associated records

handle ACM certificates via trigger
- on domain/domainCertificate deletion, ask ACM to delete the certificate via a pgboss job; removes the need to ask ACM in multiple places

clear domains that have been on HOLD for more than 30 days, check every midnight via pgboss schedule

use 'domains' profile for worker jobs
Comment thread pages/api/auth/sync.js Outdated
Comment thread pages/api/auth/sync.js
const protocol = process.env.NODE_ENV === 'development' ? 'http' : 'https'
const target = new URL(`${protocol}://${domainName}`)

target.searchParams.set('sync_token', verificationToken)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sync_token scoped to a territory? afaict it isn't but I need to walkthrough the flow more, and it might be unscoped for a reason. Given it's short lived it might not be worth scoping though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't scope sync_token because it's short lived and, hopefully, used instantly. But we can make it more secure.

Comment thread components/account.js
@huumn
Copy link
Copy Markdown
Member

huumn commented Apr 27, 2026

I qa'd the auth flow just now and it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth feature new product features that weren't there before territories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants