-
-
Notifications
You must be signed in to change notification settings - Fork 131
custom domains - auth sync #2180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Soxasora
wants to merge
78
commits into
stackernews:master
Choose a base branch
from
Soxasora:custom_domains_authsync
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
c50509a
Custom Domains CRUD, Verification
Soxasora 5e80c3f
Domains refactor, Domain Verification normalization
Soxasora 4d24845
Domains normalization: Attempts, Records, Certificates
Soxasora b624c59
Domain Verification worker adjusted to new schema; use triggers to ch…
Soxasora 89f1eb4
wip: Domain Verification worker, log all verification steps
Soxasora 9d1c137
wip: clearer Domain Verification flow, surround AWS calls with try ca…
Soxasora dc119a8
Domain Verification schema updates
Soxasora 67fb2c8
HOLD the domain and delete the certificate when a territory expires
Soxasora 725ce81
delete the certificate from ACM when we're about to STOP a territory
Soxasora f3930f7
Domain resolver refactor, use transactions, add comments
Soxasora 01e319e
Stages for Domain Verification attempts logging, fix certificate dele…
Soxasora e132ad0
separate ACM certificate requests and validation values
Soxasora cd9cb68
Domains UI/UX enhancements; core fixes to schema; general cleanup
Soxasora 9e96d7c
delete any existing domain verification jobs if we're updating the do…
Soxasora 82a71f5
Log AWS-related error messages; fix deleteCertificate recursion
Soxasora f95ab6a
fix missing await on async customDomainMiddleware
Soxasora 4f49382
Merge branch 'master' into custom_domains_base
Soxasora 2382f3b
hotfix: delete certificate from ACM also on domain removal
Soxasora c732135
Merge branch 'master' into custom_domains_base
huumn ca13d80
prepare for dnsmasq, light cleanup
Soxasora 2a77fd1
fix DNS server typo
Soxasora 072c1ae
don't ask ACM to delete a certificate in a db transaction
Soxasora 7da660a
fix typo
Soxasora d0b9467
better handling of territory changes, ACM certificates and domains in…
Soxasora 2c4ca44
address plpgsql syntax issues, move INSERT for pgboss.schedule in a f…
Soxasora 52dd035
fallback to system's default DNS servers if dnsmasq is not available/…
Soxasora 0a7eda2
better error handling of node:dns resolver
Soxasora e6bd73b
Merge branch 'master' into custom_domains_base
huumn 76be3ae
hotfix: remove the port in dev for domain mapping
Soxasora e0e2dea
add aws container to domains profile
huumn 807c2d3
move existingTXT on a more appropriate place, TODOs on prisma schema
Soxasora e8d97ba
territory redirects and rewrites for middleware, adjust navbar reacti…
Soxasora 476c10b
30 seconds of interval between verification jobs, after 1 hour of dom…
Soxasora ef549a9
also get records when getting the existing domain, recreate the domai…
Soxasora 1e3b1c6
hotfix: use validateSchema the correct way, change from domain to dom…
Soxasora 25674c2
hide custom domains from the world but the admins
Soxasora eddd453
debounce next verification jobs with a singleton key, avoiding other …
Soxasora bbf2b0a
ELBv2 implementation to attach a certificate to a load balancer; Mock…
Soxasora f36eef4
use directly the interested ELB Listener ARN via env vars; get rid of…
Soxasora 51aadf2
throw database and AWS-related errors; don't log the STAGE on critica…
Soxasora 5bf8aba
remove unused certificate attachment to ELB checks
Soxasora 1643c09
remove unused ELB env var, remove useless console.logs
Soxasora 8826def
WIP: rewrite auth sync
Soxasora 76d2da4
safer domain recognition by schema validation; no session handler wit…
Soxasora 97020e0
tie domain to the token, use it in middleware to verify token origin;…
Soxasora 109288f
verify and apply session token from Auth Sync to custom domain via mi…
Soxasora d579b55
eradicate TXT records from custom domains; adjust functions to expect…
Soxasora 102b2f2
Merge branch 'master' into custom_domains_base
Soxasora 9e2eaa2
Merge branch 'master' into custom_domains_authsync
Soxasora 1b49eed
Merge branch 'custom_domains_base' into custom_domains_authsync
Soxasora 093910b
pass CNAME record directly instead of the whole records map
Soxasora 0ad0b33
don't delete the domain if resuming from HOLD
Soxasora b69ba0a
Merge branch 'custom_domains_base' into custom_domains_authsync
Soxasora fd34d16
manual redirect to / on logout for custom domains
Soxasora ebf2c8b
wip: custom domains documentation
Soxasora f361958
docs: explain all the triggers, ACM and ALB implementations, fix head…
Soxasora 716f982
Merge branch 'custom_domains_base' into custom_domains_authsync
Soxasora 171405b
Auth Sync Rewrite - Sync API endpoint and Middleware
Soxasora de48c27
hotfix: use correct URLs for redirects; don't parse JSON from JSON
Soxasora 6a0b2cc
docs: clearer explanations
Soxasora 5a57a77
Merge branch 'custom_domains_base' into custom_domains_authsync
Soxasora e65e8a5
switch to anon on auth sync signup to allow the creation of a new acc…
Soxasora 4603878
docs: auth sync; enhance: 5 minute verification token and session cookie
Soxasora 872691b
auth sync: responses with custom domain subname headers; redirect to …
Soxasora 3b79145
cleanup: remove Auth Sync TODO from territory-domains.js
Soxasora 932f4e3
prevent CSRF attacks, consume verification token transactionally
Soxasora 236fb1b
cleanup: don't include state when redirecting back to custom domain; …
Soxasora c14ee46
cleanup: get csrfToken cookie once, bail if csrfToken cookie is not p…
Soxasora af2460b
fix: correct error redirect URL
Soxasora 1346057
pivot: encode CSRF token in a state JWT for auth sync, and decode it …
Soxasora d22eb55
encode domain and redirectUri inside state JWE
Soxasora db374b9
Revert CSRF JWE, consume verification token transactionally
Soxasora 7343cfe
security: couple domainName with JWTs to stop them from being used on…
Soxasora 19a9df2
Revert "security: couple domainName with JWTs to stop them from being…
Soxasora ac03f32
use locally scoped configs for ACM and ELB APIs
Soxasora f6c1018
Merge branch 'custom_domains_base' into custom_domains_authsync
Soxasora 5df12c9
cleanup: Auth Sync handler and middleware
Soxasora 6054532
hotfix: don't expose prisma errors while consuming a verification token
Soxasora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much, switched to token in URL as it shouldn't be logged.
Tie a CSRF token to a verification token
There were some obstacles because of the cross-domain nature, but I think I found a middle ground to safely use CSRF to tie the verification token to the user. Knowing that: - messing with next auth is not preferable and thus can't use its protections - we need to protect the token from being stolen - middleware doesn't support node We have another option, which is to **encode** the CSRF token in a _state JWE_ and store it alongside the verification token.When going to the sync endpoint, we
The sync endpoint will then
Middleware at this point will
If everything is okay, it returns the final ephemeral JWT.
Everything happens blazingly fast, if someone steals the verification token and/or the state, they can’t go that far without the CSRF token that sits and never moves in the user’s browser (well, except for the POST, but that's secure).
side note: still checking for less hacky ways/can make it less hacky