feat(leads): sign in to seed directories that gate their listings - #130
Merged
Merged
Conversation
Some directories only show their listings to a signed-in visitor. Detection could already tell that apart from an empty directory; this is the part that gets past it. Login is driven generically rather than per site. A per-directory login script is the thing worth avoiding: every gated directory would need one, and each would break on its own schedule. A login form is standardised enough to drive blind — one password field, one identifier field near it, one submit — and the password field is the anchor, so a page without one is refused rather than guessed at. The sign-in happens on the context that already hit the wall, because the redirect has put the form in front of us and the session cookies have to survive into the retry. After signing in the original URL is requested again and re-checked: signing in successfully and still being asked to log in means the account cannot see that page, which is a different problem and says so. A campaign parked on a gated directory is not failing, it is waiting on something only the user can supply. The gated hosts are recorded on the campaign, surfaced as waiting_for_auth, and each one carries the form that unblocks it — rather than leaving the reason buried in an error string nobody reads. Credentials are stored per host per organization, since a user has one account on a directory rather than one per search they paste in. Passwords exist in the database only as AES-256-GCM ciphertext, with the key in the app environment. They are deliberately not verified at save time: that would mean driving a browser through someone else's login form inside a server action, and a directory that is briefly slow would look like a bad password. The next tick tries them and records what happened, so the panel can show whether a login actually worked. A site that answers with a verification code or a challenge cannot be signed into from a server at all. That is reported as what it is instead of as a wrong password. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This was referenced Jul 28, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #128, which could tell a login wall apart from an empty directory. This is the part that gets past one.
Generic, not per-site
A per-directory login script is the thing worth avoiding — every gated directory would need one, and each would break on its own schedule. A login form is standardised enough to drive blind: one password field, one identifier field near it, one submit.
The password field is the anchor. A page without one is refused rather than guessed at, so this can't wander off filling arbitrary forms.
Submitting prefers clicking a submit button (some forms bind handlers to it) and falls back to pressing Enter in the password field (for forms whose "button" is a styled div).
Verified live against a real login form:
Session handling
Sign-in happens on the context that already hit the wall — the redirect has put the form in front of us, and the session cookies have to survive into the retry. The original URL is then requested again and re-checked: signing in successfully and still being asked to log in means the account can't see that page, which is a different problem and reports as one.
waiting_for_auth
A campaign parked on a gated directory isn't failing — it's waiting on something only the user can supply. Gated hosts are recorded on the campaign (
auth_required_hosts), surfaced in the tick summary aswaiting_for_auth, and shown in a panel where each host carries the form that unblocks it. Saving a credential clears the wait.Only counts as waiting when there's nothing to try: a stored credential that failed is an error, not a wait.
Credential storage
Per host, per organization — a user has one account on a directory, not one per search they paste in. Passwords exist in the database only as AES-256-GCM ciphertext (
lib/sp/vault.ts), key in the app environment.Not verified at save time, deliberately. That would mean driving a browser through someone else's login form inside a server action, where a briefly-slow directory looks identical to a bad password. The next tick tries them and records the outcome, so the panel shows whether the login actually worked.
Honest failure modes
A site that answers with a verification code, a second factor, or a challenge can't be signed into from a server. That's detected and reported as what it is, rather than as a wrong password.
Migration
20260728010000_outreach_seed_credentials.sql— new table plusauth_required_hostson campaigns. Already applied to prod ahead of this deploy.Checks
tsc --noEmitclean🤖 Generated with Claude Code